473,379 Members | 1,253 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

FileSystemMonitor - wait til file copies completely

Bob
I need to monitor a file system to tell when a certain file (type) has
been copied to a folder. It would seem logical to have some
pre-packaged mechanism to detect completion of the copy, but it
apparently does not exist. (The detector triggers as soon as the file
-starts- to copy, not when it's complete)

I've seen people mention hooking a call to file open into a timer. Is
there no better way to do this? Seems like there should be a much
simpler mechanism available by now.
Jan 24 '08 #1
2 8541
Bob,

The only way I have gotten around this is to have whatever process
writing the file write a "marker" file. A zero byte file to indicate that
the file writing is complete. Then, when the FileSystemWatcher detects this
file, it determines (from the filename is the system I used) the name of the
file to process, and when it is done, deletes the marker file, or both.

If you can't change the process that is outputting the file, then a
timer is really the only way you can do this. Either that, or if you know
that the process writing the file will have exclusive access to the file,
cycle in a loop (waiting in between so you don't spin the processor
needlessly) until you can get access to the file, or you time out (as
specified by you).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Bob" <Bo*@no-spam.comwrote in message
news:fi********************************@4ax.com...
>I need to monitor a file system to tell when a certain file (type) has
been copied to a folder. It would seem logical to have some
pre-packaged mechanism to detect completion of the copy, but it
apparently does not exist. (The detector triggers as soon as the file
-starts- to copy, not when it's complete)

I've seen people mention hooking a call to file open into a timer. Is
there no better way to do this? Seems like there should be a much
simpler mechanism available by now.

Jan 24 '08 #2
Try handling the Watchers Changed rather than Created event. Usually
Created is fired when the write starts, and Changed is fired again
when the write is complete and the file is closed by the writer.

On Jan 24, 4:54 pm, Bob <B...@no-spam.comwrote:
I need to monitor a file system to tell when a certain file (type) has
been copied to a folder. It would seem logical to have some
pre-packaged mechanism to detect completion of the copy, but it
apparently does not exist. (The detector triggers as soon as the file
-starts- to copy, not when it's complete)

I've seen people mention hooking a call to file open into a timer. Is
there no better way to do this? Seems like there should be a much
simpler mechanism available by now.
Jan 25 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: GTi | last post by:
Hello... I have a page located in a frame. This page contains a form. When the user submit this form I want to popup a "Please Wait" window popup window The post may take some time for the...
9
by: Vai2000 | last post by:
Hi All, Here's a situation, I am trying to process some large Files via a Win Svc using FileMonitor. During the test process I tried copy and pasting a file in a folder and got an error saying...
2
by: NBB | last post by:
I have a FileSystemWatcher set and working with the OnFileCreated event. Only thing is, it launches too quickly! I'm copying MP3 files into a directory (the directory that the FSW monitors) and...
165
by: Dieter | last post by:
Hi. In the snippet of code below, I'm trying to understand why when the struct dirent ** namelist is declared with "file" scope, I don't have a problem freeing the allocated memory. But...
5
by: pauldepstein | last post by:
I recently had a job interview question which I totally failed. (The question seemed excellent from an objective point of view, but having completely failed to do it, my subjective feelings are...
1
by: peterggmss | last post by:
This is a slot machine game, 2 forms. One is the actual game (frmMachine) and the other is in the background and randomizes the images shown on frmMachine. I need to make frmMachine wait for...
1
by: John | last post by:
I have code that copies a file using fs.CopyFile. In the routine I would like Access to wait with further execution until the copying is done. How can I accomplish this? Thanks, john
22
by: Jason Zheng | last post by:
This may be a silly question but is possible for os.wait() to lose track of child processes? I'm running Python 2.4.4 on Linux kernel 2.6.20 (i686), gcc4.1.1, and glibc-2.5. Here's what happened...
2
by: huwfriedhoff | last post by:
Hi Guys, I have a friend who is developing a dvd store in Visual basic ( It's a WPF application) and stores the data in an XML file. the content of the XML look like this: <DVDInfo> <DVD>...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.