System.IO.File.Move to move an existing file into another folder. However it the program is stopping at this point with the error message "The process cannot access this file because is being used by another process". Unfortunately I can't find "the other process". For the record, I've also tried
System.IO.File.Copy which works fine. However when I try to delete the original file, I get the same message.
Here's the full code I'm using:
Dim objReader As New System.IO.StreamReader(getRestranName(i)) fileName = getRestranName(i) If System.IO.File.Exists(fileName) Then Do While objReader.Peek() <> -1 txtLine = objReader.ReadLine() prpName = Trim(Microsoft.VisualBasic.Left(txtLine, 30)) destinationFile = destinationFolder & "\" & Trim(Microsoft.VisualBasic.Right(fileName, 15)) If prpName = propertyName Then System.IO.File.Move(fileName, destinationFile) End If Exit Do Loop End If
Is this issued happening because I have "fileName" still open as "objReader"? If this is the case, is there a way to close it while still in my loop?
As always, thanks for your help.