473,288 Members | 2,725 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,288 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 2281
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...

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.