Archived

This topic is now archived and is closed to further replies.

Draco5869

Delete a certain line of txt file

Recommended Posts

Draco5869    122
Alrighty, i want to delete a certain line in a text file (finding it by comparing it to the one i wanna delete) How should i go about this (in VB, plz). ----------------------------------------------------------- Like a sponge!

Share this post


Link to post
Share on other sites
dalleboy    324
There are no spoon... and there are no lines in files, there are only characters. You must interpret a bunch of characters as a line yourself.

Pseudocode:


for each line in original file that shouldn't be deleted:
   output line to another file
delete original file
rename other file to the original file


[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]

[edited by - dalleboy on August 11, 2003 4:47:24 AM]

Share this post


Link to post
Share on other sites
Draco5869    122
i ended up just reading each line into an array and then deleted the thing i wanted from the array and then rewrote all the contents... but will this mess up other things trying to access the file or will it be too quick to ever notice?

-----------------------------------------------------------
Like a sponge!

Share this post


Link to post
Share on other sites
Colin Jeanne    1114
quote:
Original post by Draco5869
i ended up just reading each line into an array and then deleted the thing i wanted from the array and then rewrote all the contents... but will this mess up other things trying to access the file or will it be too quick to ever notice?


It depends on the size of the file and it depends on the sharing enabled for the file. The way you deleted the line is one way to delete part of a file.



Qui fut tout, et qui ne fut rien
Invader''s Realm

Share this post


Link to post
Share on other sites