Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemWatcher - Multiple Files

Status
Not open for further replies.

Skittle

ISP
Sep 10, 2002
1,528
0
0
US
I need to write a simple windows service program to react each time a file is added to a folder. My research indicates the FileSystemWatcher is the tool to use within a VB.Net Service program.

I do however haver a question.

How will a FileSystemWatcher service program react when two files are added to the folder at about the same time?.

Consider the first is a very large file and the second is a very small file added a milisecond later. The first large file will start to be pocessed and will still be in pogress when the second small file arrives. Will the service process both files at the same time or will it process the big one first and then process the little one. Could the second little file vene not be picked up at all because the first one takes up the service program's attention for so long?




Dazed and confused.

Remember.. 'Depression is just anger without enthusiasum'.
 
DO not have an offical answer, but to be safe what about after processing a file that was kicked off via the FileSystemWatcher thr program does a quick check for any other files? In fact after processing any files it does a check?

Lion Crest Software Services
Anthony L. Testi
President
 
I have tried it out based on an example in the Wrox book, 'VB 2005 with .Net 3.0' and found a few abstract atricles on the subject.

It appears that all file events are buffered in the sequence they occur and are processed one at a time. So if a big file triggers a file event and a small file pops up during the big file process, you will get both files processed by the service program.

The key is the FileSystemWatcher buffer size. The default buffer size is 4K which I read somewhere is enough to store 80 file names. So as long as you have an appropriately high buffer size, all files should be processed.

The reason I had this question is that the SQl server Integration services version of the filewatcher does not buffer these events and the big file would indeed block out the small file.


Dazed and confused.

Remember.. 'Depression is just anger without enthusiasum'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top