By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 1,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

FileSystemWatcher Question

P: n/a
I have been asked to write a program to monitor a certain directory
structure and to copy all files created there to optical media for archival
storage. It seems that it would be simple to monitor the directory for
file creation and just copy the files. I am concerned that while doing the
copy a "Created" event may get lost and the file not get archived. How
would I handle this?

Would it be feasible to put the paths of the newly created files into a FIFO
queue and to have a separate thread monitor the FIFO and do the copying?
Would that work? If so, how would I go about creating and running the
separate thread. I've never dealt with threads before. Also, would it be
better to have more that one thread, or is that asking for trouble?

TIA,

--
Al Reid
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I thought I would have gotten some input, thoughts or suggestions.

"Al Reid" <ar*****@reidDASHhome.com> wrote in message news:%2******************@TK2MSFTNGP11.phx.gbl...
I have been asked to write a program to monitor a certain directory
structure and to copy all files created there to optical media for archival
storage. It seems that it would be simple to monitor the directory for
file creation and just copy the files. I am concerned that while doing the
copy a "Created" event may get lost and the file not get archived. How
would I handle this?

Would it be feasible to put the paths of the newly created files into a FIFO
queue and to have a separate thread monitor the FIFO and do the copying?
Would that work? If so, how would I go about creating and running the
separate thread. I've never dealt with threads before. Also, would it be
better to have more that one thread, or is that asking for trouble?

TIA,

--
Al Reid

Nov 21 '05 #2

P: n/a
Well, in the absence of any input telling me not to do it, I went ahead an coded up a prototype. It monitors a directory structure
for creation and change events and places the events into a shared queue. A worker thread monitors the queue and performs the copy
operations into a "mirror" location. It seems to be working well and I don't seem to be loosing any events, even when monitoring a
network share.

The only puzzling thing is that I get multiple events for the same file at times. It looks like I get 1, 2 or 3 events in sequence.
Perhaps I'm getting separate change events for file size, last write time, etc. Does anyone have any suggestions as to how to
handle this. Worst case, it just copies/overwrites the file multiple times to the same location.

Thanks for your input and insight.

--
Al Reid

"Al Reid" <ar*****@reidDASHhome.com> wrote in message news:%2******************@TK2MSFTNGP11.phx.gbl...
I have been asked to write a program to monitor a certain directory
structure and to copy all files created there to optical media for archival
storage. It seems that it would be simple to monitor the directory for
file creation and just copy the files. I am concerned that while doing the
copy a "Created" event may get lost and the file not get archived. How
would I handle this?

Would it be feasible to put the paths of the newly created files into a FIFO
queue and to have a separate thread monitor the FIFO and do the copying?
Would that work? If so, how would I go about creating and running the
separate thread. I've never dealt with threads before. Also, would it be
better to have more that one thread, or is that asking for trouble?

TIA,

--
Al Reid

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.