I am using the following statement to define and open an input file:
The above works beautifully. However, within the processing statements, there is a condition in which the file that is being read is finished and the file needs to be deleted (after a backup copy is generated).Code:Dim fileList As IO.FileInfo() = dirInfo.GetFiles(currentCtrl.DemoName + "INPUT*") For Each inFile As IO.FileInfo In fileList <processing statements> NEXT
The problem is that the fileList (IO.FileInfo()) statement still has hold of the file and the file cannot be deleted because the following error is received:
"The process cannot access the file because it is being used by another process "
I need to close the file before it is deleted, however I do not see the method within the FileInfo Class(System.IO).
Is there a trick to closing this file within the IO.FileInfo?
Thanks,
JV




Reply With Quote