Search code examples
c#triggersfilesystemsfilesystemwatcher

Monitor changes to file system in c#


I know of the FileSystemWatcher, but the scope of this is what bothers me. I want to be able to detect if a user creates a file, anywhere on the computer. When using FileSystemWatcher, if the change is not directly in the directory you are watching, it will not specify any file names, whats more, I have found if the change is more than 2 directories away from the watched directory, no event is triggered.

What would be the best way to go about this? Are there any libraries that I can maybe have a look at?


Solution

  • FileSystemWatcher can monitor the full drive and any depth (if IncludeSubdirectories = true) but if there is much activity you may need to increase the internal buffer (http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.internalbuffersize.aspx).