Text File

  • Thread starter Thread starter Chris Wilmot
  • Start date Start date
C

Chris Wilmot

I have a text file and want to move down say 10 lines then update that line
but only updating the one line.

Is there an easy way of doing this ????

Thanks in advance

Chris Wilmot
 
Chris Wilmot said:
I have a text file and want to move down say 10 lines then update
that line but only updating the one line.

Is there an easy way of doing this ????

No, unless all lines are equal in length. Otherwise you have to read the
whole file starting with the 10th line, change it and write it back to the
file, again starting at the position of the 10th line.
 
Hello,

Chris Wilmot said:
I have a text file and want to move down say 10 lines then
update that line but only updating the one line.

Is there an easy way of doing this ????

When using lines of fixed length, you need to replace the line only (classes
FileStream, StreamWriter, StreamReader). Otherwise you must read in all
lines behind the line you want to write, then write the new line
(overwriting) and save the rest of the lines (from the buffer) to the file.

Regarsd,
Herfried K. Wagner
 
Hi Chris,

You can use a filesystemobject and then seek for x number of chr(10) +
chr(13) (carriage return, line feed characters).

HTH,

Bernie Yaeger
 
¤ *tuts* We really want to stop people from using the FSO. It's a bad thing.
¤ :-)

You mean the native .NET methods are better, not that FSO is bad. ;-)


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top