Hi,
I wrote a small program that copy a list of files to a specified folder one
by one, i.e. this app will copy one file into the specified folder and wait
until it's consumed (deleted) then copy another one in. Here is what my
code:
// other codes to get a list of files
while (morefiles)
{
// copy one file to destination
string destFileName = "DestFileName";
System.IO.File.Copy(sourceFileName, destFileName);
// wait for the file being removed
watcher.Path = txtTargetFolder.Text ;
watcher.Filter = Path.GetFileName(destFileName); //only interested if
this file gets deleted
watcher.NotifyFilter = NotifyFilters.FileName ;
watcher.WaitForChanged(WatcherChangeTypes.Deleted) ;
}
It works OK if no other application would touch the destination folder - it
stop working if someone else drop a file into the destination folder and
that file gets deleted, after that this watcher will longer re-act to any
file deletion.
Is this a bug of FileSystemWatcher or there is a flaw in my solution?
Thanks very much!
John