S
Steve
I have a FileSystemWatcher watching a directory where I will add and update
files. When it detects a change, I search through all the files and update
my list of files in the UI. This works fine.
Now, my other application that is writing the files that are being watched,
does something like this:
1) Creates a file, a.txt
2) wants to name it b.txt but checks first if b.txt exists, if it does, it
delete it
3) moves a.txt to b.txt (rename)
what happens is that when b.txt is deleted, my other app that is watching
that folder starts processing the files in the directory(Creating FileInfo
objects, etc) In that processing, it's looping through a collection of
files that WERE there when it was initiated.
Then the call to Move() happens and now the FileSystemWatcher app has
invalid data as it hasn't returned fast enough to finish before the move()
call happened.
I hope this makes sense to someone. Basically, application A is deleting
resources that Application B is still working with.
Do I just catch the FileNotFoundException and deal with it? Any design
suggestions to work with this scenario?
files. When it detects a change, I search through all the files and update
my list of files in the UI. This works fine.
Now, my other application that is writing the files that are being watched,
does something like this:
1) Creates a file, a.txt
2) wants to name it b.txt but checks first if b.txt exists, if it does, it
delete it
3) moves a.txt to b.txt (rename)
what happens is that when b.txt is deleted, my other app that is watching
that folder starts processing the files in the directory(Creating FileInfo
objects, etc) In that processing, it's looping through a collection of
files that WERE there when it was initiated.
Then the call to Move() happens and now the FileSystemWatcher app has
invalid data as it hasn't returned fast enough to finish before the move()
call happened.
I hope this makes sense to someone. Basically, application A is deleting
resources that Application B is still working with.
Do I just catch the FileNotFoundException and deal with it? Any design
suggestions to work with this scenario?