473,467 Members | 1,487 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

FileSystemWatcher and multiple changed events

D2
Hi,

I have this problem when working with FileSystemWatcher class. I m
using one of these objects to watch over a folder. Whenever i big file
from another folder to the folder being watched, I get created event
and multiple changed events.
After the file is copied (fully) i want to read the file and perform
some operations on it. Now the issue is, there is no way to find that
the file has been copied entirely.

there are some workarounds like try to open file in a loop until u r
successful (this is the time when file got copied). This has a
potential problem, if I copy large number of files, it will skip about
50% of them .. depending on the size of files being copied.

Any better solutions?

Thanks,
D2

May 11 '07 #1
1 2636
D2,

Is the file being copied part of a controlled environment? In other
words, is the file being copied as the result of an operation from a client
which you have control over, or is it meant as a general file monitoring
system?

There was a system where I needed to process files once they were
dropped in a directory. I wanted to use the file system watcher, but I
couldn't know for sure when the writing of the file was complete. Because
we were in control of the client, we made it so that the client wrote a zero
byte marker file which would tell the FileSystemWatcher when to process the
original file. Since the marker file was zero bytes, one could reasonably
assume that the marker file and original file were both closed by the end of
processing.

Perhaps you could do something similar?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"D2" <dh*****@yahoo.comwrote in message
news:11*********************@e65g2000hsc.googlegro ups.com...
Hi,

I have this problem when working with FileSystemWatcher class. I m
using one of these objects to watch over a folder. Whenever i big file
from another folder to the folder being watched, I get created event
and multiple changed events.
After the file is copied (fully) i want to read the file and perform
some operations on it. Now the issue is, there is no way to find that
the file has been copied entirely.

there are some workarounds like try to open file in a loop until u r
successful (this is the time when file got copied). This has a
potential problem, if I copy large number of files, it will skip about
50% of them .. depending on the size of files being copied.

Any better solutions?

Thanks,
D2

May 11 '07 #2

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

Similar topics

4
by: Josh Usovsky | last post by:
I'm setting up a watched folder using FileSystemWatcher. When I drop a small file into the watched folder, I can respond to a .Created event and process the file with other code. However, if I try...
0
by: cxw0106 | last post by:
Hello, I have some weird problem with the FileSystemWatcher. I have developed an application that monitors a network directory for file changes of a certain file type. The program runs well for...
3
by: Michael Stanbrook | last post by:
I'm using the FileSystemWatcher to looks for new files arriving in a directory. Files are coming in via FTP and tend to be larger is size (> 1MB at least). I would like to fire an event once the...
5
by: Jon Maz | last post by:
Hi there, I am experimenting with the FileSystemWatcher object. I have set the NotifyFilter as follows: myFileSystemWatcher.NotifyFilter = NotifyFilters.Security | NotifyFilters.CreationTime...
10
by: Kai Thorsrud | last post by:
Hi i'm an event Noob and i'm calling a class from my main module console app like this. I'm sorry if this is a lot of code to read but i can't see the error according to my book. Thanks a LOT. ...
2
by: DiGa | last post by:
Hi all I have to write an application in VB.NET which monitors multiple files at the time and notifies the user about changes. I thought to use multiple instances of FileSystemWatcher in an...
1
by: Abel Chan | last post by:
Hi there, I was trying to write a simple NT services using .NET 2.0 and fileSystemWatcher control. The goal is to poll documents from a watch directory and ftp them to a remote web site. I...
12
by: ljh | last post by:
Has anyone else noticed that the FileSystemWatcher raises the changed event twice when a file is changed? Do you have any idea why this is the case?
1
by: teslar91 | last post by:
I've been learning VB.NET for the past few weeks. One of the problems I've run into is difficulties updating controls in events from certain components, such as the FileSystemWatcher, that raise...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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
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...

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.