G
Guest
I'm trying to get a FileSystemWatcher configured to watch for changes to only
one file. All I desire is for the "Changed" event to fire once every time
this file is written to. With the code I have now, the event is being fired
_four_ times when I only expect it once. Can anyone advise me on what may be
wrong?
Here is the code:
private FileSystemWatcher configureProcessListWatcher()
{
string processListPath =
ConfigurationSettings.AppSettings["ProcessListPath"];
FileInfo fi = new FileInfo(processListPath);
FileSystemWatcher watcher = new FileSystemWatcher(fi.DirectoryName,
fi.Name);
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.EnableRaisingEvents = true;
watcher.Changed += new FileSystemEventHandler(watcher_Changed);
return watcher;
}
---- END CODE -----
In my event handler, watcher_Changed, I open the file that is being watched.
Could this possibly trigger the event to fire again the way that I have this
set up?
Thanks for any help.
one file. All I desire is for the "Changed" event to fire once every time
this file is written to. With the code I have now, the event is being fired
_four_ times when I only expect it once. Can anyone advise me on what may be
wrong?
Here is the code:
private FileSystemWatcher configureProcessListWatcher()
{
string processListPath =
ConfigurationSettings.AppSettings["ProcessListPath"];
FileInfo fi = new FileInfo(processListPath);
FileSystemWatcher watcher = new FileSystemWatcher(fi.DirectoryName,
fi.Name);
watcher.NotifyFilter = NotifyFilters.LastWrite;
watcher.EnableRaisingEvents = true;
watcher.Changed += new FileSystemEventHandler(watcher_Changed);
return watcher;
}
---- END CODE -----
In my event handler, watcher_Changed, I open the file that is being watched.
Could this possibly trigger the event to fire again the way that I have this
set up?
Thanks for any help.