Question Cannot Delete Text File

akom

New member
Joined
Sep 12, 2012
Messages
2
Programming Experience
5-10
I have a strange problem that is bugging me. I have a VB.NET 2010 program that works great opening, converting,writing to a new file and saving the converted output to a new text file at a different location. However, I want to delete the original input file once I am done with it but it just won't go away. Also, I am logged in as an administrator on the machine I am running this on.

Here are the pertinent lines that are being used that refer to my issue:


Imports System.IO
CODE
InName = "F:\WWTP\op10.imp" 'Input file path
CODE
oRead = IO.File.OpenText(InName) 'Open the input file (This works just fine & outputs to different path variable)
CODE
System.IO.File.Delete(InName) 'Delete the input file (This does nothing and the file is still there after the program finishes)


I've even tried dropping the "System.IO" part because I saw an example like that somewhere. Any suggestions would be greatly appreciated.

Thanks in advance,
Al
 
I figured out what it was... I had forgotten to close the input file before I went to delete it. I knew it had to be something simple.

Thanks anyway,
Al
 
Back
Top