473,387 Members | 1,365 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,387 software developers and data experts.

FileSystemWatcher monitor newly created file

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 entirely written. Is there anyway
to achieve this?

Thanks.

Daniel
Jul 9 '07 #1
3 2286
Hi Daniel,

I performed a test based on your description and saw the same thing as you
did.

In my test, I watch all .txt files in a specified folder and set the
NotifyFilter property of the FileSystemWatcher as follows:

watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite |
NotifyFilters.LastAccess ;

Run the application. Open the Windows Explorer and navigate to the
specified folder. As soon as I create a new txt file in the folder, the
Created event of the FileSystemWatcher is fired. Then I rename the new
file's name, and the Renamed event of the FileSystemWatcher is raised.

Press the Enter key and the new txt file is opened in Notepad. Type some
textes in the file and save the changes. At this time, the Changed event of
the FileSystemWatcher is fired.

I suggest that you use the Changed event of the FileSystemWatcher component
to get notified after a file being entirely written on disk.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 9 '07 #2
Hi,

"Daniel" <da*********@newsgroup.nospamwrote in message
news:55**********************************@microsof t.com...
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 entirely written. Is there
anyway
to achieve this?
The FileSystemWatcher is sometimes a pain to work with. For reasons like the
one you are encountering. In short the answer to your question is NO. You
can still do it but you have to use different techniques depending of your
escenario.
If you cnotrol the file creation (maybe it's generated by anothe rprocess)
the easiest is to create a second file (a "flag" file) and has the
FileSystemWatcher check fr it, when you see it you know that there is
another file with the same name that contains the data.

If this is not a possible solution then you will have to do a try/error
until you can read the file, additionally you have to be carefull not to
process the file twice. !!!
Jul 9 '07 #3
Hi Daniel,

How about the problem now?

If you still need our further assistance, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Support Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Jul 12 '07 #4

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

Similar topics

1
by: Mike | last post by:
I'm running into a problem where the FSW events report all filenames in lower case. (The directory portion is okay, just the leaf file name is broken.) I found this thread from 6/02 stating as...
2
by: Jim Hubbard | last post by:
I want to develop an installation watcher to watch over programs as they install themselves to the PC. The FileSystemWatcher will enable me to see all files created or changed within any...
2
by: Paul | last post by:
Hi, I've been developing an application in VB.NET that uses the FileSystemWatcher and a popup notification in order to tell me when files have been downloaded. The FileSystemWatcher code in...
1
by: Primo | last post by:
Hello, I am building a data management application with the following processes: Process 1 is a Windows service which uses FileSystemWatcher to monitor a directory. Process 2 opens a file...
1
by: John Lee | last post by:
Hi, I developed a filewatcher service to monitor file creation on a network drive - 90% time it works fine and from time to time I found out that the newly created file on that network drive...
20
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...
2
by: Al Reid | last post by:
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...
2
by: DWalker | last post by:
I need to monitor a folder to see when a file that is being FTP'ed into the folder is finished. I have looked at the doc for the FileSystemWatcher and the Created event. It's not clear from the...
4
by: Stefan L | last post by:
Hi NG, I have a file driven application (a report server) which has to do some work when new files arrive or are deleted. When processing the notifications about newly created files from a...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...

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.