473,473 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2037
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ron | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
0
by: simpsoro | last post by:
I am trying to run asp.net pages. The server is accessed by students via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and...
0
by: Phil396 | last post by:
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...
2
by: David Meier | last post by:
Hi all, I know, windows does not care about cases in file names, however, I need to get the file name returned from the FileSystemWatcher case sensitive. Does anyone know a workaround to this...
0
by: Ron Simpson | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
4
by: carmelo | last post by:
Hi! I need to read and store data from a file, but I don't the name of it; Is this code correct and is there a better way to do this thing?? int main() { cout << " type file name:" char *...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
4
rahulephp
by: rahulephp | last post by:
i think i am missing something in the below script: It shows error an do not upload files to destination: Let me know how to solve this: <?php if (isset($_POST)) { $uploadArray=...
4
by: liberty1 | last post by:
Hi everyone. I appreciate your effort at helping newbies like me. I have the following problems and will appreciate urgent help. PROBLEM NUMBER 1: Using PHP and MySQL, I am able to upload...
0
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...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.