"ToddT" <tu********@maritzSPAM.com> wrote in message
news:9c********************************@4ax.com...
i've got one app that writes large files to a specific directory that
is watched by another app via an instance of the file system watcher
class. my problem is that the second app is notified when files are
created, but the first app hasn't finished writing to it - causing a
"file is already open" error when the second app trys to open the file
for processing. what i need is a "file closed" event to be thrown by
the file system watcher object. any idea how i can get around this
problem? thx.
I have got around this kind of issue in the past with various ruses, none of
them entirely satisfactory, but they may help. I am assuming that the second
app is yours...
1. Don't open the file if its length is zero (if the first app writes all
its data in one go this may be the case, depending on the windows version)
2. Build some delay in to the second app so that it doesn't try and open the
file within n seconds or minutes of the LastWriteTime of the file, available
via the FileInfo object. You will need to make the delay n configurable so
you can tune the second app to correspond to the size of file being
received.
Good luck!
--Jim.