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
EventLog.WriteEntry(Me.ServiceName, Me.ServiceName & " File found = " & strFileName, EventLogEntryType.Information)
e = Nothing
Try
File.Delete(strFileName)
Catch ex As Exception
EventLog.WriteEntry(Me.ServiceName, Me.ServiceName & " fsWatcher_Created Delete File " & ex.ToString, EventLogEntryType.Error)
End Try
</code>
The log indicates that the file is found, it writes to the event viewer the proper filename and path, then it logs that the delete attempt failed, reason given: the file is in use by another process.
I am assuming that it is the filewatcher itself that has the file? If so how do I make it 'let go'?
I have used the following code:
<code>
strFileName = e.FullPath.ToString
EventLog.WriteEntry(Me.ServiceName, Me.ServiceName & " File found = " & strFileName, EventLogEntryType.Information)
e = Nothing
Try
File.Delete(strFileName)
Catch ex As Exception
EventLog.WriteEntry(Me.ServiceName, Me.ServiceName & " fsWatcher_Created Delete File " & ex.ToString, EventLogEntryType.Error)
End Try
</code>
The log indicates that the file is found, it writes to the event viewer the proper filename and path, then it logs that the delete attempt failed, reason given: the file is in use by another process.
I am assuming that it is the filewatcher itself that has the file? If so how do I make it 'let go'?