473,804 Members | 3,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FileSystemWatch er: problems with event-catching

Hi,

we have some problems with the following situation:
A remote application A writes files to a directory monitored by a
FileSystemWatch er-instance in application B. A creates the file
with the initial ending "COPY_IN_PROGRE SS" and only after
successful copying the file gets renamed to its final ending
"TO_DO". The FileSystemWatch er of B is set to react on the
rename-event and upon recognizing an event some processing
is triggered.
Now the problem is that obviously the event is raised and also
recognized, however the renamed file seems to not yet exist
within the filesystem: the given RenamedEventArg s contain the
new filename, however a File.Exists on this filename, executed
first within the OnEvent-method, returns with false.
Though, if some trace messages are inserted before the File.Exists
everything is working fine, so it seems that there might be some
sort of timing problem. Is it possible that the rename event is
raised before completion of the file system update.
Does anyone know something about this problem or has a solution
ready? (inserting some delay wouldn't be a proper solution; a
completely event-driven solution is preferred)

Thanks in advance
Andreas

Nov 15 '05 #1
1 4522
The Rename and create events of the filesystemwatch er both are quite
eager -- that is, you get the events early, and may not be able to yet
access the file in question.

For any application / service I have written using the FSW, I've normally
done the following
1) Upon getting the event, spawn a "processing thread" and start it up
2) in the processing thread, try to access the file repeatedly until
sucessful (sleeping a bit in-between tries)
3) Let the processing thread completely process the file, the notify the
application thread that the contents are ready.

"Andreas" <Am*******@gmx. net> wrote in message
news:1075727236 .354573@nbgm66x ...
Hi,

we have some problems with the following situation:
A remote application A writes files to a directory monitored by a
FileSystemWatch er-instance in application B. A creates the file
with the initial ending "COPY_IN_PROGRE SS" and only after
successful copying the file gets renamed to its final ending
"TO_DO". The FileSystemWatch er of B is set to react on the
rename-event and upon recognizing an event some processing
is triggered.
Now the problem is that obviously the event is raised and also
recognized, however the renamed file seems to not yet exist
within the filesystem: the given RenamedEventArg s contain the
new filename, however a File.Exists on this filename, executed
first within the OnEvent-method, returns with false.
Though, if some trace messages are inserted before the File.Exists
everything is working fine, so it seems that there might be some
sort of timing problem. Is it possible that the rename event is
raised before completion of the file system update.
Does anyone know something about this problem or has a solution
ready? (inserting some delay wouldn't be a proper solution; a
completely event-driven solution is preferred)

Thanks in advance
Andreas

Nov 15 '05 #2

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

Similar topics

4
9121
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 copying a large file into the watched folder, the .Created event is fired off immediately and not when the file is finished copying. I have tried waiting for a certain number of .Changed events to be fired after the initial .Created event, and...
0
1319
by: Lloyd Sheen | last post by:
I have created a FileSystemWatcher application that monitors a set of folder for changes. This works well as a windows app. I have copied the code from the windows app to a windows service and now there are problems. If I perform add/chg/del in the folder, the windows app captures all changes (actually to a degree that I did not know happened - ie. 4 events for an add of a file). The windows service though will not pick up add's to...
1
3334
by: Troy Murphy | last post by:
How do I prevent the FileSystemWatcher event to keep firing while the file is being created? When copying a file to the watched folder, the event fires a dozen or more times! Also, the documentation states that if more than one file is copied to the folder at the same time, a cache will queue them up for processing, but when I drop 3 files into this folder, only the 1st (sometimes the first two) cause the event to fire. Thanks, Troy
3
7842
by: Craig Thompson | last post by:
I've attempted to write a windows service that creates one FileSystemWatcher for each entry in a XML config file. Everything start perfrectly and runs as I expect for about 5 minutes and then after that the FileSystemWatchers seem to stop monitoring... My theory is that for some reason the Garbage Collector is trashing my FileSystemWatchers. Another clue to my situation is that I just took my service and made it into a windows form...
2
2282
by: Bonnett | last post by:
I have made a simple console application that creates a webpage from my playlist, then uploads it to my webhost. I decided to convert it to a windows service and use the FileSystemWatcher to monitor the playlist file, this is where i became stuck. I know the service detects changes to the playlist as when running the Change event of FileSystemWatcher, I add an item to the event log. I've tried making the service without including the...
1
4623
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 does not trigger the event - all I have to do is to restart the service. I kind of suspect the reason is when the target matchine where monitored drive is on gets rebooted, the filesystemwatcher lost its "monioring" capability, is that true? if...
3
14313
by: Stampede | last post by:
Hi, I want to use the FileSystemWatcher in a Windows Service. I read an article, where the author created the FileSystemWatcher object in a seperate thread and when the event is fired, he started a working thread for processing the file, created a new FileSystemWatcher (as he said for real time processing), and then called the join method for the first thread. I can't really see the sence in this. Aren't the events of the...
20
4513
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 logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my Global.asax and everything works fine.I have found FileSystemWatcher class not very reliable and sometimes it behavies unexpectedly.I'm afriad that...
2
2006
by: kmcnet | last post by:
Hello Everyone and thanks for your help in advance. I have been battling a problem for nearly a month with the FileSystemWatcher component. Basically, what I am trying to do it to monitor three separate folders on a Windows 2000 server for activity. In my code, I have set up three separate subroutines: FaxWatch() ReportWatch() ScheduleWatch() Each of the subroutines creates a new instance of the FileSystemWatcher.
1
2366
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 their events in different threads. I found plenty of examples on the Web of how to "detangle" the threads, using Delegate functions, .InvokeRequired, and .Invoke. But all of these examples demonstrated how to do it on a single form. I wanted...
0
9704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9132
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.