I am kicking off a File System Watcher in a system tray application. It monitor’s a text file in a local folder. But the FS_changed event is fired only once after starting the application.
FileSystemWatcher fWatch = new FileSystemWatcher();
fWatch.BeginInit();
fWatch.Path = Path.GetTempPath();
fWatch.Filter = "File1.txt";
fWatch.Changed += new FileSystemEventHandler(fWatch_Changed);
fWatch.EnableRaisingEvents = true;
fWatch.EndInit();
I am not handling the Created/Deleted, kind of events. But I tried those as well(just to check) and they are not being called at all although that local file is being deleted and created during this process.
Any ideas/suggestions?
It’s probably getting garbage collected. Are you keeping a reference to that object?