Replacing a line in a file

krsh24

Active member
Joined
Sep 16, 2006
Messages
25
Programming Experience
3-5
Hi,

I have a file (.dat). The size of the file can grow upto 20 Mb or above. The requirement is to delete the last line in the file and to replace it with a new line.

Any suggestions on how i can achieve this?

I don't want to copy the entire contents to another file skipping the last line and appending the new line.
Also reading each line into a string array would decrease the performance coz the number of line could increae more than 10,000.

Thank You
Krsh
 
don't quote me on this, just talking out loud...

is there not a method in the IO which allows something like....

file.readlast(size in bytes) and use that to just read the last bit you need, modify and write back
 
Back
Top