So it makes be wonder if Notepad is indeed performing more than one write/save operation when I click the Notepad Save menu item. And the OnFileChanged event only fires one time for each text file change. I tried updating the text file from code using. String aFilepath = Now I'm starting to think this may be a MS Notepad issue. Private void OnFileChanged(object source, FileSystemEventArgs e)Ĭonsole.WriteLine("OnFileChanged" + ctr) Watcher.Changed += new FileSystemEventHandler(OnFileChanged) Watcher.NotifyFilter = NotifyFilters.LastWrite String fileName = Path.GetFileName(path) String folderName = Path.GetDirectoryName(path) Private void FileWatcherSetup(string path)įileSystemWatcher watcher = new FileSystemWatcher() So maybe we can hold this issue open for a while? A coder reading this could have an idea to help. I need to investigate more time to explore behavior of code in a Windows service. Maybe it has something to do with Windows messaging on specific servers. So I guess I am not the only person having trouble with this. This is from the documentation of the class. I am afraid that this is a well-known bug/feature of the FileSystemWatcher class. I noticed this behaviour years ago to face this again now. The main difference is that this this custom filewatcher class is implemented in a Windows service executable. In fact I am getting System.IO.IOExceptions at on our production servers. I was not able to reproduce this behavior on my machine. Just tried to create a reproducable example but failed □.
0 Comments
Leave a Reply. |