T
Tom P.
I am writting a file manager. My network at work is so slow I am now
using a background worker to get the files and make ListViewItems then
add them to the main thread.
I also use a DirectorWatcher to update the file list when something
happens. The DirectoryWatcher in my app sees the change and calls the
background worker to update the files that were affected.
The problem I think I have is when a person is editing a file (a Word
doc specifically). I don't know why but Word apparently creates temp
files and then deletes them right away. So my DirectoryWatcher will
see a change and set off the background worker. The background worker
will try to create the new item but by this time the file is gone and
the background worker gets an exception trying to access it.
I check in the DirectoryWatcher if the change is a delete or create, I
check in the constructor of the ListViewItem if the file exists. Both
come back fine... then I get a FileNotFound exception when I try to
get the file size.
How do I keep up with this? Do I lock the file in the
DirectoryWatcher? But then Word can't clean-up after itself correctly
and we'll end up with a bunch of "~*.tmp" files on the network.
How many times can I check if the file exists before I can trust that
the file does in fact exist? I can't just keep checking every couple
of lines.
Any ideas?
Thanks,
Tom P.
using a background worker to get the files and make ListViewItems then
add them to the main thread.
I also use a DirectorWatcher to update the file list when something
happens. The DirectoryWatcher in my app sees the change and calls the
background worker to update the files that were affected.
The problem I think I have is when a person is editing a file (a Word
doc specifically). I don't know why but Word apparently creates temp
files and then deletes them right away. So my DirectoryWatcher will
see a change and set off the background worker. The background worker
will try to create the new item but by this time the file is gone and
the background worker gets an exception trying to access it.
I check in the DirectoryWatcher if the change is a delete or create, I
check in the constructor of the ListViewItem if the file exists. Both
come back fine... then I get a FileNotFound exception when I try to
get the file size.
How do I keep up with this? Do I lock the file in the
DirectoryWatcher? But then Word can't clean-up after itself correctly
and we'll end up with a bunch of "~*.tmp" files on the network.
How many times can I check if the file exists before I can trust that
the file does in fact exist? I can't just keep checking every couple
of lines.
Any ideas?
Thanks,
Tom P.