472,785 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,785 software developers and data experts.

The process cannot access the file ...

Hello , I have windows service which do listening to specified directory
using FileSystemWatcher , on Created Event and Get all the files in the
directory using Directory.GetFiles function then foreach file in the files
list and passed the file path to a function to read its content then process
it then move it to another directory
am reading each file content using StreamReader...ReadToEnd function, all
process working fine , That when 50 files are copied simultanously there are
no error , but when more than this like 60 or 80 or more a error messages
logged to error log like following

Error in Message Object-> MessageObject.SendMessage() (C:\queue\
26e54303de8e431c81f9e1004c427590.msg) >>The process cannot access the file
"C:\queue\ 26e54303de8e431c81f9e1004c427590.msg" because it is being used by
another process.

How Can I effectively avoid this problem?????

Nov 17 '05 #1
2 7706
You need to post your code I think. This may get you a better chance of a
solution.

--
Terry Burns

http://TrainingOn.net


"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
Hello , I have windows service which do listening to specified directory
using FileSystemWatcher , on Created Event and Get all the files in the
directory using Directory.GetFiles function then foreach file in the files
list and passed the file path to a function to read its content then
process
it then move it to another directory
am reading each file content using StreamReader...ReadToEnd function, all
process working fine , That when 50 files are copied simultanously there
are
no error , but when more than this like 60 or 80 or more a error messages
logged to error log like following

Error in Message Object-> MessageObject.SendMessage() (C:\queue\
26e54303de8e431c81f9e1004c427590.msg) >>The process cannot access the file
"C:\queue\ 26e54303de8e431c81f9e1004c427590.msg" because it is being used
by
another process.

How Can I effectively avoid this problem?????

Nov 17 '05 #2
Hello Raed,

Your message is difficult to read.

Here's what I think you said. Please correct me (using sentences with
periods, please).

You use FileSystemWatcher to be informed of an event.
You then scan the directory and files tree getting all files.
You open the file, process it, and move it to another directory.

When you find 50 files, you do not get an error.
When you find 60-80 files, you get errors that some of the files are being
written by another process.

Sounds like the process that is writing the files isn't done with them yet.

Note that FileSystemWatcher will return an event when a single file is
modified. You will get the name of the file. You appear to be ignoring the
name of the file and you are searching the directory for other files. This
means that you will get files that are not finished being written yet.

Why not just trust the FileSystemWatcher to send you the name of each file?
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
Hello , I have windows service which do listening to specified directory
using FileSystemWatcher , on Created Event and Get all the files in the
directory using Directory.GetFiles function then foreach file in the files
list and passed the file path to a function to read its content then
process
it then move it to another directory
am reading each file content using StreamReader...ReadToEnd function, all
process working fine , That when 50 files are copied simultanously there
are
no error , but when more than this like 60 or 80 or more a error messages
logged to error log like following

Error in Message Object-> MessageObject.SendMessage() (C:\queue\
26e54303de8e431c81f9e1004c427590.msg) >>The process cannot access the file
"C:\queue\ 26e54303de8e431c81f9e1004c427590.msg" because it is being used
by
another process.

How Can I effectively avoid this problem?????

Nov 17 '05 #3

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

Similar topics

9
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...
4
by: Mountain Bikn' Guy | last post by:
I am having serious problems with the following IDE bug: Could not write to output file 'x.dll' -- 'The process cannot access the file because it is being used by another process. ' and BUG:...
3
by: trellow | last post by:
Hello, I am writing an application that needs to read a file that is already open by another process for writing. When I do the following: FileStream fs = new FileStream(fileName,...
3
by: guoqi zheng | last post by:
Dear sir, There is an import tool on my web application, user can upload Ms Access file, the file is saved at a temp folder on the server. After the import is finished, for security reason, I...
0
by: Sin | last post by:
> Xxxxx : error PRJ0008 : Could not delete file 'd:\xxxxxxx.dll'. > Make sure that the file is not open by another process and is not write-protected. > > LINK : fatal error LNK1168: cannot open...
5
by: ZWeng | last post by:
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...
0
by: imranabdulaziz | last post by:
Dear All, I am making web application using Asp.net C#(Visual Studio2005). And Sql server 2005 as a back End I generated local mode report but as there was no printing option available . I assign...
0
nightangel
by: nightangel | last post by:
Hi dude,what i was done in my application is uploading a image file to my server using FTP, it work great when pushing a file into the server path using FTP. The problem i met now is i need to do a...
4
by: =?Utf-8?B?VkIgSm9ubmll?= | last post by:
I am at my witless end here, please help! I have an ASP.Net aspx web page, hosted on Windows Server 2003, that receives a query string with the path to an autocad drawing file selected from a...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.