Here is my current scenario
1- I have 2 windows services The first one called "SrvAnalyse" analyse some data and put the results in a file in a specific folder "TempFolder".
2- The 2nd service "SrvUploadFiles" is listening to "TempFolder", once there is a file in there it will upload it to a certain link then move the file to a backup folder
The 1st service takes some time in analysing the data. so it starts writing the file and keep writing till the analysis finishes.
Now the problem is that the 2nd service will start working immediatly once a file is in that folder before SrvAnalyse finishes.
the result is incomplete file upload and error when file start to be moved to the backup folder due it's been used bby another process.
Here is my code
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = Folder;
watcher.NotifyFilter = NotifyFilters.FileName;
watcher.Filter = "*.*";
watcher.Created += new FileSystemEventHandler(OnCreated);
watcher.EnableRaisingEvents = true;
I can't think of any way to resolve this!!
any idea how to fix this problem?