Hi NG,
I have a file driven application (a report server) which has to do some
work when new files arrive or are deleted.
When processing the notifications about newly created files from a
FileSystemWatcher I want to open the file and read some info from it.
Problem is that when opening the file directly when the event is fired I
usually get a "file used by another process".
Has anyone figured out a good way how to handle such events? Is there an
option to get a notification when the file is created and can be read?
My other alternatives I thought about, were:
1. Use a FIFO in a second thread that processes the files which are new.
Should keep iterating (with a short Thread.sleep) until all files are
imported successfully.
2. Start a worker thread from the pool for each file which tries to read
it in.
3. Forget about FileSystemWatcher and check the directory for new files
every 30 secs (Timer driven) [but how to reco if files have changed here?].
Does anyone has experience with this? Any best practices?
TIA,
Stefan