
Deleting Records in Text Files
Because the length of the records in a text file is variable, and
because the file is generally processed as a stream, the standard method
for deleting data is to make a new copy of the file consisting of the
correct stream of data. This is scarcely a workaround.
However, given your particular requirements, you can probably achieve
what you require by reading the file backwards as binary (perhaps in 1k
increments), finding the eof, identifying the third to last cr/lf pair
(possibly the delimiter is just cr or lf, but in most files they occur
as a pair), and writing a single byte - an eof (x1a) - immediately
thereafter.
Quote:
> Dear Group,
> I have a text file that I have converted from the older MBF file. I would
> like to be able to delete the last two lines of the file.
> I understand that I can recreate the text file into a new file and just
> leave out the data that I dont want. This seams like a workaround and not a
> solution.
> I also understand that I can erase the characters in the records, but I
> would still be left with stuff on the record. Meaning the EOF function
> would not trigger the end of file.
> Any help would be appreciatted.
> Kindest Regards,
> Matt Stecher