Jump to content
  • Advertisement

Archived

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

Draco5869

Delete a certain line of txt file

This topic is 5425 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
I guess, but it''d be good to be able to delete the line too.

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

Share this post


Link to post
Share on other sites
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
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
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
Guest Anonymous Poster
whats this got to do with games?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!