I created a windows service using FileSystemWatch er to moniter a folder for
file drops. The service uses FileStream and StreamReader to read and process
the file. After it is done, the file is copied to a different location and
deleted in the original folder.
If files coming in in short intervals (under sub-second) on XP OS, there is
an error occured occassionally with the follow message:
System.IO.IOExc eption: The process cannot access the file, because it is
being used by another process.
at System.IO.__Err or.WinIOError(I nt32 errorCode, String str)
at System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
Boolean bFromProxy).
However, on W2K OS, the error could happen even with 5 sec interval between
file droppings.
I am not sure if this is a load related issue especially on the W2K box.
Any suggestions and comments would be appreciated. My environment is XP with
Framework 1.1 as Dev box and the Production Server is W2K with Framework 1.1.
Both environment has the 1.1 SP1 installed.
Thank you 5 8725
> I created a windows service using FileSystemWatch er to moniter a folder for file drops. The service uses FileStream and StreamReader to read and process the file. After it is done, the file is copied to a different location and deleted in the original folder.
If files coming in in short intervals (under sub-second) on XP OS, there is an error occured occassionally with the follow message: System.IO.IOExc eption: The process cannot access the file, because it is being used by another process.
What kind of filtering do you have? only changes to the files? new files?
etc.
Do you retry if the file is in use? Your code could be triggered because
the application created the file and is still writing to it.
--
Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/
mailto:la***@vk arlsen.no
PGP KeyID: 0x2A42A1C2
The NotifyFilters = NotifyFilters.F ileName;
I am not sure what you mean of "Do you retry if the file is in use?". And
this seems to be the problem as the application is still reading/writing
while a new file is dumped in the monitoring folder.
Thank you.
ZW
"Lasse Vågsæther Karlsen" wrote: I created a windows service using FileSystemWatch er to moniter a folder for file drops. The service uses FileStream and StreamReader to read and process the file. After it is done, the file is copied to a different location and deleted in the original folder.
If files coming in in short intervals (under sub-second) on XP OS, there is an error occured occassionally with the follow message: System.IO.IOExc eption: The process cannot access the file, because it is being used by another process.
What kind of filtering do you have? only changes to the files? new files? etc. Do you retry if the file is in use? Your code could be triggered because the application created the file and is still writing to it.
-- Lasse Vågsæther Karlsen http://usinglvkblog.blogspot.com/ mailto:la***@vk arlsen.no PGP KeyID: 0x2A42A1C2
Need to check the existance and accessibility before process the file as the
FSW event is triigged when the file is still creating and not accessible yet.
See posting FileSystemWatch er + Monitor Reads/Opens on 1/16/06 for reference.
"ZWeng" wrote: I created a windows service using FileSystemWatch er to moniter a folder for file drops. The service uses FileStream and StreamReader to read and process the file. After it is done, the file is copied to a different location and deleted in the original folder.
If files coming in in short intervals (under sub-second) on XP OS, there is an error occured occassionally with the follow message: System.IO.IOExc eption: The process cannot access the file, because it is being used by another process. at System.IO.__Err or.WinIOError(I nt32 errorCode, String str) at System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy).
However, on W2K OS, the error could happen even with 5 sec interval between file droppings.
I am not sure if this is a load related issue especially on the W2K box. Any suggestions and comments would be appreciated. My environment is XP with Framework 1.1 as Dev box and the Production Server is W2K with Framework 1.1. Both environment has the 1.1 SP1 installed.
Thank you
It sounds like your trying to access the file before it has completed
writing to the disk.
"ZWeng" <ZW***@discussi ons.microsoft.c om> wrote in message
news:81******** *************** ***********@mic rosoft.com... I created a windows service using FileSystemWatch er to moniter a folder for file drops. The service uses FileStream and StreamReader to read and process the file. After it is done, the file is copied to a different location and deleted in the original folder.
If files coming in in short intervals (under sub-second) on XP OS, there is an error occured occassionally with the follow message: System.IO.IOExc eption: The process cannot access the file, because it is being used by another process. at System.IO.__Err or.WinIOError(I nt32 errorCode, String str) at System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy).
However, on W2K OS, the error could happen even with 5 sec interval between file droppings.
I am not sure if this is a load related issue especially on the W2K box. Any suggestions and comments would be appreciated. My environment is XP with Framework 1.1 as Dev box and the Production Server is W2K with Framework 1.1. Both environment has the 1.1 SP1 installed.
Thank you
Not me, the FileSystemWatch er Class is trying to access the file before it
has completed writing to the disk. Microsoft offered a greate class to
watch for the files, but programmers have to handle the issue not accessing
the file before it has completed writing to the disk.
"gman" wrote: It sounds like your trying to access the file before it has completed writing to the disk.
"ZWeng" <ZW***@discussi ons.microsoft.c om> wrote in message news:81******** *************** ***********@mic rosoft.com...I created a windows service using FileSystemWatch er to moniter a folder for file drops. The service uses FileStream and StreamReader to read and process the file. After it is done, the file is copied to a different location and deleted in the original folder.
If files coming in in short intervals (under sub-second) on XP OS, there is an error occured occassionally with the follow message: System.IO.IOExc eption: The process cannot access the file, because it is being used by another process. at System.IO.__Err or.WinIOError(I nt32 errorCode, String str) at System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy).
However, on W2K OS, the error could happen even with 5 sec interval between file droppings.
I am not sure if this is a load related issue especially on the W2K box. Any suggestions and comments would be appreciated. My environment is XP with Framework 1.1 as Dev box and the Production Server is W2K with Framework 1.1. Both environment has the 1.1 SP1 installed.
Thank you This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil Galey |
last post by:
I have a FileSystemWatcher that triggers when a PDF file is created.
However, the creation of the PDF file is about a 7 or 8 second process ... I
cannot refer to the file during that time because it does not yet exist. If
I set up a loop using the Sleep API call, it loops forever and the software
that creates the PDF file stops progressing and the file never finishes
getting created. The FileSystemWatcher was triggered only on the...
|
by: Bill |
last post by:
I created a Windows Service (written in VB.NET) that uses a FileSystemWatcher
to monitor a directory for file creation. When files with a certain
extension are created in the directory, the file is opened and read
(something is done with the contents). Then the file is moved to a backup
directory. Everything works fine when the coe runs as a standard Windows app,
but when I run the code as a Windows Service, I get the following error when...
|
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: Steel City Phantom |
last post by:
i am building a content distribution system using the filesystemwatcher
to catch people moving files in and out of the system and update a
database. what happens is when a process runs that moves hundreds of
files (happens every day) i get all kinds of debug errors and an
unhandled exception. here is the debug log
First-chance exception at 0x7c342eee (msvcr71.dll) in VoiceScanner.exe:
0xC0000005: Access violation reading location...
|
by: Phil396 |
last post by:
I have a windows service that uses a filesystemwatcher
to wait for files and process them to a database.
Sometimes a large group of files will be cut and paste
for the filesystemwatcher to process. I ran into
trouble when trying to process a group of files
at a time.
The code below fixed my problem for about 15 large files
( around 100k each ). However when I tried to use it
on a group of small files ( 90 files ) it crashes (
around 6k...
| |
by: Paul |
last post by:
Hi,
As most people who use the FileSystemWatcher know, it returns lowercase text
for some strange reason. I know there's a workaround for the lowercase the
FileSystemWatcher returns by by passing the 'FullPath' property into the
constructor of a DirectoryInfo Class and reading the 'Name' property but I'm
not sure how or where I'd fit that into my code.
Could someone point me in the right direction?
Cheers,
Paul
|
by: Tushar |
last post by:
Followup-To: microsoft.public.dotnet.general
Does anyone know when is this event raised, is it:
1) When the file is created but may not have been closed
2) When the file is created AND it has been closed
I am using this control in a Windows-Service I've developed. It works hoever
the problem I'm having is that the file does not seem to be available when I
receive this event. If I include a delay of a few seconds using Sleep(3000)
for...
|
by: Mahita |
last post by:
Hi,
I am coding a Windows Service in which I am using the "OnCreated" event of
FileSystemWatcher class to do some processing when a new file is created in a
particular folder. However I have encountered the following issue in the
"OnCreated" event of FileSystemWatcher class.
Whenever a file is copied from a different folder (like network share) and
pasted to the monitoring folder and this copy & paste process takes time,
even before the...
|
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
FileSystemWatcher I want to open the file and read some info from it.
Problem is that when opening the file directly when the event is fired I
usually get a "file used by another process".
|
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: 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,...
| |
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...
|
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: 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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |