How drop a text file?

  • Thread starter Thread starter BGCSOCAL
  • Start date Start date
B

BGCSOCAL

I'm designing the error logic for a VB2005 console application that reads
Excel files from a folder, one at a time, and writes a text file for each
when called by a script. I'm using streamwriter to write the text file. If I
trap an error and want to throw the text file away cleaning up all the
associated resources, how do I do that?

I reviewed MSDN on streamwriter's methods but none looked promising. The
closest was dispose, but I had trouble understanding the article and it
didn't feel right.

Please be patient if I don't reply promptly. I am not getting my
notifications and ahve to remember to check the forum. My apologies in
advance.
 
I'm designing the error logic for a VB2005 console application that reads
Excel files from a folder, one at a time, and writes a text file for each
when called by a script. I'm using streamwriter to write the text file. If I
trap an error and want to throw the text file away cleaning up all the
associated resources, how do I do that?

I reviewed MSDN on streamwriter's methods but none looked promising. The
closest was dispose, but I had trouble understanding the article and it
didn't feel right.

Please be patient if I don't reply promptly. I am not getting my
notifications and ahve to remember to check the forum. My apologies in
advance.

File.Delete

Try
Using sw As New StreamWriter(outputPath)
' Do cool stuff
End Using
Catch ex As Exception
' do stuff with your exception
If File.Exists(outputPath) Then File.Delete (outputPath)
End Try
 
Back
Top