Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete a line in a text file

Status
Not open for further replies.

MAM

Programmer
Sep 12, 2000
5
US
I understand how to write and read to a text file; however, I'm trying to figure out how to delete a line of text within a text file. Is this possible? The only way I've figured out how to do it so far is to rewrite the entire text file to a new file and remove the desired line during the writing of the new file. Is there an easier/faster way to delete text within a text file? [sig][/sig]
 
You might want to check out the Truncate procedure (I/O routines). You should be able to find the line you want to delete, truncate the file at that line and shuffle everything after that line up in some sort of way. I would have to set down and try this but it should work.

Hope this helps.

Brett Parkhurst [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top