Delete a certain line of txt file

Started by
6 comments, last by Draco5869 20 years, 8 months ago
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!
-----------------------------------------------------------Like a sponge!
Advertisement
You could output over it with blank spaces, if that''d suit your program..not sure about deleting.
lol
I guess, but it''d be good to be able to delete the line too.

-----------------------------------------------------------
Like a sponge!
-----------------------------------------------------------Like a sponge!
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]
Arguing on the internet is like running in the Special Olympics: Even if you win, you're still retarded.[How To Ask Questions|STL Programmer's Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
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!
-----------------------------------------------------------Like a sponge!
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
What''s ur sig mean invader? Jw...

-----------------------------------------------------------
Like a sponge!
-----------------------------------------------------------Like a sponge!
whats this got to do with games?

This topic is closed to new replies.

Advertisement