Hi,
I have some problems to detect when a file is changed by another application
(the file is changed several times by the application). Sometimes, its is
correctly detected, sometimes not. Below is a part of my code. Is there
anybody who can help me
....
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = "C:\\TEMP;
watcher.NotifyFilter = NotifyFilters.LastWrite ;
watcher.Filter = "file1.ini";
mszStatus = "Start";
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.EnableRaisingEvents = true;
method.mfStart(); // This will start the external program
// Wait so that the method is completed.
while (String.Compare(mszStatus,"Stop") != 0)
{
System.Threading.Thread.Sleep(10);
}
.....
// Define the event handlers.
private void OnChanged(object source, FileSystemEventArgs e)
{
.... // Look in the file for a specific string
if (....) // If string = finished
{
mszStatus = "Stop";
}
}