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 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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.
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |