Hi,
I have experimeneted several problems with FileSystemWatcher which are explained on this forum, such as multiple events or events firing too soon.
I'm monitoring 2 directories with 2 FileSystemWatcher objects for specific (and different) filenames, one of the directory is a sub of the other. I monitor both changed and created events. The problem is that when the file being monitored in the parent directory gets created the event handler associated to the file in the subdirectoy also gets fired. Note that in both cases I do set the IncludeSubdirectories attribute to false.
Of course I can handle this by verifying the file name at the beginning of each event handler but still it is annoying (and caused me a fair bit of pain before I figured out what appened).
This is what I do (in distinct methods) for both directories:
//Create a new FileSystemWatcher and set its properties.
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher();
fileSystemWatcher.Path = dirToWatch;
fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
fileSystemWatcher.IncludeSubdirectories = false;
string fileName;
fileName = "whatever.txt";
fileSystemWatcher.Filter = fileName;
// Add event handlers for creation and modification.
fileSystemWatcher.Changed += new FileSystemEventHandler(OnChanged);
fileSystemWatcher.Created += new FileSystemEventHandler(OnChanged);
//Begin watching.
fileSystemWatcher.EnableRaisingEvents = true;

FileSystemWatch firing wrong event!!!
Michelle A.
Now when I dump a file manually in one folder but it triggers 2 distinct event handlers that are supposed to monitor different directories and filter different filenames.
2162
Dhaval Mistry
Tryin2Bgood
I think this could be due to the fact that the two monitored directories have a parent-child relationship.
I will post if this is indeed the problem, in which case it would be a Microsoft bug.
Emadkb
Nasty bug in our software caused this.