Preventing files being added to a directory

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

Is there an easy way to design a service that "listens" for attempts to
add files to a specified directory, and on detecting an attempt
starting another exe? I've no idea how feasible it is without getting
too deep into the WinAPI.
 
Greg,

You need to go deeper than the API for this. You need to write a system
level driver which will handle this, and you can't really do it in .NET (you
could write an unmanaged stub which will call managed code, but you can't
create the dll using managed code. Also, I don't know that system level
code should be managed, necessarily).

If you want to just trigger an action when something happens, the
FileSystemWatcher is what you want. However, it won't let you change the
action, which I think is what you are after.

Hope this helps.
 
Thanks a lot Nicholas.

I'm definitely not prepared to start writing system level drivers, but
the FileSystemWatcher will do the trick - there are easy ways around my
problem now that I know about this class!

Thanks again,

Greg.
 
Back
Top