I created a windows service using FileSystemWatcher 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.IOException: The process cannot access the file, because it is
being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String 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 8696
> I created a windows service using FileSystemWatcher 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.IOException: 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***@vkarlsen.no
PGP KeyID: 0x2A42A1C2
The NotifyFilters = NotifyFilters.FileName;
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 FileSystemWatcher 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.IOException: 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***@vkarlsen.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 FileSystemWatcher + Monitor Reads/Opens on 1/16/06 for reference.
"ZWeng" wrote: I created a windows service using FileSystemWatcher 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.IOException: The process cannot access the file, because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String 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***@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com... I created a windows service using FileSystemWatcher 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.IOException: The process cannot access the file, because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String 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 FileSystemWatcher 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***@discussions.microsoft.com> wrote in message news:81**********************************@microsof t.com...I created a windows service using FileSystemWatcher 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.IOException: The process cannot access the file, because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String 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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |