[Resolved]
I used a hybrid, your code and the line of thought I was on before I saw your code (I went with a half second because I just hate to wait ;) ):
Try
strFileName = e.FullPath
Do While IO.File.GetAttributes(strFileName) = FileAttributes.Offline
'Wait 1/2 second before trying...
[Resolved]
You got it! AHA!
I was using the copy command (command line) to move a number of files into the 'watched' directory. You suggested maybe the weren't done copying.
I added a simple loop, I count to 10 million THEN try to delete. Works like a charm.
I will be looking for some...
I really appreciate you taking the time to try that. I used you code (cut an pasted it. I added code to write errors to the event log since this is a service and there is no interface. I get this:
Event Type: Error
Event Source: SpendTrackImportSvc
Event Category: None
Event ID: 0
Date...
Have a look at the code I posted (first posting). It has the exact same problem and it is much simpler. If I can figure out how to release the file for deletion (the code posted) then I can use the same logic to release the file to read it.
Thanks.
(By the way... isn't it the middle of the...
I need to read the xml file. Parse it (using an XMLReader) then store the information in a database.
Once that is done I need to delete the file.
I have tried to read the file, delete the file, rename the file... anything I could think of to get control of the file so that I can do SOMETHING...
You have stated that you are using an admin account, is this a local (on the server with the service) or remote admin account?
IE: does the same username and password work as an admin on BOTH servers?
Is the SQL server using Integrated security?
What is the error you are getting? Are you...
I am working on an application which will allow users to ftp xml files onto our web-server. A windows service using filewatcher will 'see' the file, bring it in, process it, then delete it.
I have used the following code:
<code>
strFileName = e.FullPath.ToString...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.