Hi all,
I am using a streamreader to read txt files. This all works fine, but once it's done, I want to copy the text file to another location. In order to do this, I should close the streamreader, in order for the system to release the txt file right?

Well, this seems not to be working. I call streamreader.close.... but it doesn't release my txt file...

This is some of my code:


VB Code:
  1. Select Case whatToDo
  2.     Case "V"
  3.         theFile.Delete()
  4.     Case "B"
  5.         sr.Close()
  6.         IO.File.Move("C:\Netcash\DebitProcessor\2_Verification\" & theFile.Name, "C:\Netcash\DebitProcessor\3_MasterBatch\" & theFile.Name)
  7.     Case "C"
  8.         sr.Close()
  9.         IO.File.Move("C:\Netcash\DebitProcessor\2_Verification\" & theFile.Name, "C:\Netcash\DebitProcessor\3_MasterBatch\" & theFile.Name)
  10. End Select


and this is my error:




An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll

Additional information: The process cannot access the file "C:\3_MasterBatch\19642632673021796427000.txt" because it is being used by another process.

Thanks