I have developed a Windows Service application that uses a file watcher to
watch for new files being dumped into an directroy. As soon as it sees a
new file, it moves it to a different directory for it to be processed. In
the processing I use a streamreader to pull each line for parsing into a
database.
The problem, is that the first file after the service is started works as
expected, but any subsequent files that is put in the directory cannot be
moved to the processing directory. I get the following error message:
"The process cannot access the file "\\Server\Share\Directory\newfile.txt"
because it is being used by another process."
After using File.Move(OrigFile, NewFile) I call the processing class which
uses a streamreader that I close and set to nothing after completion. I
then set the processing class to nothing.
Any suggestions or ideas??
TIA,
Jim