473,498 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileSystemWatcher Question

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
2 1276
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1439
by: Hardy Wang | last post by:
Hi, I have a FileSystemWatcher object to monitor one certain folder on server. FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = @"C:\MyFolder"; watcher.NotifyFilter =...
13
9112
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just...
3
2692
by: Krish | last post by:
Hello Gurus, Pardon me for asking dumb question... I wrote small csharp program to watch a folder for any created text file... When i try to run through debugger and stop after "...
1
1810
by: Terry | last post by:
I have created a Windows Service application which uses FileSystemWatcher to monitor multiple folders and file filters. These folders/files are loaded from a database table. When a Change Event...
20
4413
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
1
1685
by: dinny | last post by:
Question about FileSystemWatcher: How can I determine if a delete notification was a file or a directory. I was using the DirectoryInfo.exists method to determine if I am receiving file or...
9
7093
by: Tushar | last post by:
Followup-To: microsoft.public.dotnet.general Does anyone know when is this event raised, is it: 1) When the file is created but may not have been closed 2) When the file is created AND it has...
3
2290
by: =?Utf-8?B?RGFuaWVs?= | last post by:
I'm working with the FileSystemWatcher which has a Created event. But this event is raised as soon as the new file begins to be written on disk. What I want is a notification after a file being...
5
5550
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher,...
7
2551
by: =?Utf-8?B?Tmljaw==?= | last post by:
Hello, I've got a FileSystemWatcher object setup to check for new files in a folder. I've never done much with threading, but I think I mght need to here. When I find a new file there are times...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.