By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,187 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,187 IT Pros & Developers. It's quick & easy.

FileSystemWatcher file name error

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.