473,756 Members | 6,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

file system watcher question

i've got one app that writes large files to a specific directory that
is watched by another app via an instance of the file system watcher
class. my problem is that the second app is notified when files are
created, but the first app hasn't finished writing to it - causing a
"file is already open" error when the second app trys to open the file
for processing. what i need is a "file closed" event to be thrown by
the file system watcher object. any idea how i can get around this
problem? thx.
Nov 21 '05 #1
2 1022
> i've got one app that writes large files to a specific directory that
is watched by another app via an instance of the file system watcher
class. my problem is that the second app is notified when files are
created, but the first app hasn't finished writing to it - causing a
"file is already open" error when the second app trys to open the file
for processing. what i need is a "file closed" event to be thrown by
the file system watcher object. any idea how i can get around this
problem? thx.


Another thing you can do is have your application that generates the file
generate it a temporary location, and then File.Move() it to the "drop zone"
that the other application is listening on.

--
Peace & happy computing,

Mike Labosh, MCSD

"Mr. McKittrick, after very careful consideration, I have
come to the conclusion that this new system SUCKS!"
~~ General Barringer ~~
"ToddT" <tu********@mar itzSPAM.com> wrote in message
news:9c******** *************** *********@4ax.c om...
Nov 21 '05 #2
Jim
"ToddT" <tu********@mar itzSPAM.com> wrote in message
news:9c******** *************** *********@4ax.c om...
i've got one app that writes large files to a specific directory that
is watched by another app via an instance of the file system watcher
class. my problem is that the second app is notified when files are
created, but the first app hasn't finished writing to it - causing a
"file is already open" error when the second app trys to open the file
for processing. what i need is a "file closed" event to be thrown by
the file system watcher object. any idea how i can get around this
problem? thx.


I have got around this kind of issue in the past with various ruses, none of
them entirely satisfactory, but they may help. I am assuming that the second
app is yours...

1. Don't open the file if its length is zero (if the first app writes all
its data in one go this may be the case, depending on the windows version)
2. Build some delay in to the second app so that it doesn't try and open the
file within n seconds or minutes of the LastWriteTime of the file, available
via the FileInfo object. You will need to make the delay n configurable so
you can tune the second app to correspond to the size of file being
received.

Good luck!

--Jim.
Nov 21 '05 #3

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

Similar topics

9
715
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit anyway).... Private Sub LogChange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs) If e.ChangeType = WatcherChangeTypes.Created Then
1
1814
by: jnc | last post by:
I have quite a weird problem whereby I need to obtain the username of the person who has a file open and it need to work over the nework. To explain a bit more.....I have a file system watcher which is watching a file over the network. The file can be opened by multiple users from mutiple computers within the same domain. Currently the file system watcher object (sits on a server watching out on the network) will tell me when the file...
3
4145
by: Ron Vecchi | last post by:
Hi all, Can someone point me in the direction on this one, resources or examples. I am writing a Windows Service to monitor a folder. When I file is modified within the folder or any subfolders it should write the name of the file to a xml file. Then at a specifed time all the files in the xml quene will be backed up on a network share. How would I go about monitoring a folder and all subfolders and detect when
7
4123
by: Allen Anderson | last post by:
I'm trying to figure out a way to catch when a file has been written to a directory. I currently have it where I can catch when the file begins writing, but this isn't helpful as I need to know when its done. Does anyone know the right combination of flags to use to catch when the file has been written and closed? (here is my current code). // member variable FileSystemWatcher watcher = new FileSystemWatcher();
0
2568
by: Jack David | last post by:
I am using the following code to monitor a directory for new files. The problem is that when I add a new file to the directory the code creates two events??? what do I have to do to limit it to only one event?? using System; using System.IO; namespace DirectoryWatcher
2
3309
by: Jack David | last post by:
Using the code below I am able to monitor a single directory for a new file and then kick-off a process to deal with the file. The question is??? How would I modify this code to be able to monitor a couple of different directories and based upon the directory where the new file is created kick-off a process Example: File A in Directory B starts process C
5
2024
by: ToddT | last post by:
i've got one app that writes large files to a specific directory that is watched by another app via an instance of the file system watcher class. my problem is that the second app is notified when files are created, but the first app hasn't finished writing to it - causing a "file is already open" error when the second app trys to open the file for processing. what i need is a "file closed" event to be thrown by the file system watcher...
17
2707
by: spentun | last post by:
How can I moitor file which is executed by user or program in window. I need to write a code to monitor file. When user clicks the file(.exe) or is called by program, the name of file will be return to a program. so, excatly, I need to know the name of the executable file that is executed. originally, I try to windows service + FileSystemWatcher. but, There are just created, renamed, deleted, and changed four events in the...
2
2798
by: TwistedPair | last post by:
All, This is sort of a continuation of a previous post of mine. The code below basically reads a registry key to get a path to a folder and it watches for files created in that folder (only created). It also reads another registry key for another path which is a destination path. When a file shows up, it copies it off. It actually works well . . . For small duty stuff but if for example I were to copy in multiple small files...
6
1695
by: Andy B | last post by:
What would i use to look for changes in a file every minute?
0
9454
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
10028
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...
1
9836
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9707
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
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
7242
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
5301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3352
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2664
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.