I am watching for changes in a .log file that is being written by a software of an industrial machine.
The software is continously writing but no changes are detected by FileSystemWatcher.
However, when I open the Windows Explorer and navigate to the watched directory, suddenly FileSystemWatcher detects inmmediatly the last change and fires. (quite strange).
I am configuring the watcher as:
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = "C:\\nextgen\\log";
watcher.NotifyFilter = NotifyFilters.DirectoryName |
NotifyFilters.LastAccess |
NotifyFilters.LastWrite |
NotifyFilters.FileName |
NotifyFilters.Size |
NotifyFilters.Attributes | NotifyFilters.CreationTime;
// Only watch logfiles.
watcher.Filter = "*.log";
// Add event handlers.
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created+= new FileSystemEventHandler(OnChanged);
// Begin watching.
watcher.EnableRaisingEvents = true;