delete contents of text file

P

Poppy

I use the following code to append a line of text to a text file :

Dim myFILENAME As String = Server.MapPath("/ABACUS/cvdocs/" & fileName)
Dim objStreamWriter As StreamWriter
objStreamWriter = File.AppendText(myFILENAME)
objStreamWriter.WriteLine(csvline)
objStreamWriter.Close()

The code works fine but I need to be a ble to delete the entire contents of
the file as well and I cant figure it out.

How can I open a text file and clean it out ?

Thanks in Advance
 
K

Kevin Spencer

Just create an empty text file and overwrite the existing one.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Poppy

If I can add lines to a textfile I dont know why I cant empty it.
I am already deleting it and recreating it bit I was wondering if there was
another solution.
 
K

Kevin Spencer

The simplest solution is NOT to delete the file, but simply create it. Sorry
if I wasn't clear on that point. It isn't necessary to delete it; creating
it will overwrite.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top