File monitor/copy code doesn't catch everything

File monitor/copy code doesn't catch everything

Post by Chris Duna » Sun, 25 Mar 2007 05:56:59



What you see as 'simultaneous' copying of several files, to the
computer is probably not simultaneous at all. It probably sees the
creation of the first file and then kicks off it's processing, not
getting an event for the other files. One possible way of getting
around this is when you see the create event, get a list of ALL files
that match your criteria and then copy them all.


Same as above, once the 500Mb file appears, the file system watcher
fires the created event and your code launches into the long process
of copying the file. Other files copied after that, don't get
events.

One method would be to simply have your FileSystemWatcher add the
filename to a queue or list and then go back to watching for files.
The copying process could be kicked off using a background thread
which continually monitors the queue and if a filename is found there,
copies it. So you would have two separate processes. One which uses
the FileSystemWatcher to monitor for files and insert their names into
a queue and another to watch the queue and do the actual copying.

Hopefully this will give you some ideas.

Chris
 
 
 

File monitor/copy code doesn't catch everything

Post by TwistedPai » Sun, 25 Mar 2007 11:42:17

Yes it does! I was wondering if that was indeed the best way to handle it,
and now I suppose I have confirmation. Now all I have to do is figure out
how. Thank you for your pointers, and any others would be greatly
appreciated as well!