How drop a text file?

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.
 
T

Tom Shelton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top