471,347 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,347 software developers and data experts.

Preventing files being added to a directory

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.

Nov 30 '05 #1
2 907
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Greg" <gr*************@yahoo.co.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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.

Nov 30 '05 #2
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.

Nov 30 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.