469,610 Members | 1,862 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

FileSystemWatcher file name error

I have a Windows service that use a FileSystemWatcher
to scan incoming html for information. The process
worked fine in a Windows Application and it also
works fine in a Windows Service except when you try
to process the same file name twice. I get the generic
problem "file is being used by another process". What
is really stange is it will report the same
problem when the name is different but the first 10
letters are the same. I have seen some people who
have had similar problems use thread sleep but I do
not believe that will help me in anyway since the
problem only occurs if I try to use the same file name.

Nov 16 '05 #1
2 1887
Phil,

Can you show some code which shows how you are accessing the file? Is
it possible you are not closing some handles to the files that you are
trying to access perhaps?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil396" <an*******@discussions.microsoft.com> wrote in message
news:97****************************@phx.gbl...
I have a Windows service that use a FileSystemWatcher
to scan incoming html for information. The process
worked fine in a Windows Application and it also
works fine in a Windows Service except when you try
to process the same file name twice. I get the generic
problem "file is being used by another process". What
is really stange is it will report the same
problem when the name is different but the first 10
letters are the same. I have seen some people who
have had similar problems use thread sleep but I do
not believe that will help me in anyway since the
problem only occurs if I try to use the same file name.

Nov 16 '05 #2
It is a threading problem. I step through the program
line by line and everything worked fine. I am trying
some way to use thread sleep to slow down that application
if this exception occurs

private void BCEfileSystemWatcher_Created
(object sender, System.IO.FileSystemEventArgs e)
{

string myFileName = e.FullPath;
objProductEvents.ReadAllEvents(myFileName);
}

-----Original Message-----
Phil,

Can you show some code which shows how you are accessing the file? Isit possible you are not closing some handles to the files that you aretrying to access perhaps?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Phil396" <an*******@discussions.microsoft.com> wrote in messagenews:97****************************@phx.gbl...
I have a Windows service that use a FileSystemWatcher
to scan incoming html for information. The process
worked fine in a Windows Application and it also
works fine in a Windows Service except when you try
to process the same file name twice. I get the generic
problem "file is being used by another process". What
is really stange is it will report the same
problem when the name is different but the first 10
letters are the same. I have seen some people who
have had similar problems use thread sleep but I do
not believe that will help me in anyway since the
problem only occurs if I try to use the same file name.

.

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by simpsoro | last post: by
reply views Thread by Phil396 | last post: by
reply views Thread by Ron Simpson | last post: by
4 posts views Thread by carmelo | last post: by
185 posts views Thread by jacob navia | last post: by
rahulephp
4 posts views Thread by rahulephp | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.