Delete all records in a text file except first line

From vb 6, how to delete all records in a txt file keeping only first line (column header or field names) intact.

thanks.
LVL 34
Mike EghtebasDatabase and Application DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jaime OlivaresSoftware ArchitectCommented:
Hi eghtebas,
Have a look to this previous question:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20549308.html

Good luck,
Jaime.
0
_agj_Commented:
why not read in the first line, delete the file and write to it newly?

dim strBuf as string

open "fil1.txt" for input as #1
Line input #1, strBuf
close #1
Kill "fil1.txt"
open "fil1.txt" for output as #1
Print #1, strBuf
close #1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike EghtebasDatabase and Application DeveloperAuthor Commented:
Hi  _agj_,

Your solution is more suitble to use in my application.  I am testing it now.

Hi Jaime,

Thank you for the link.  I don't have complication (requiring the file has to exist and can't be deleted, etc.).  

Regards,

mike
0
vinnyd79Commented:
Just a note,you don't need to kill the file in agj's example because when you open it for output the file will be overwritten.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.