Text File

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
 
A

Armin Zingler

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.
 
H

Herfried K. Wagner

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
 
B

Bernie Yaeger

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
 
P

Paul Clement

¤ *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)
 
T

Tom Spink

lol, There is a reason why I hate it, I'm not entirley certain, but it's
nagging at the back of my mind.

It's probably just my prejudice against COM. :)

--
Happy to help,
-- Tom Spink
([email protected])

http://dotnetx.betasafe.com >> On The Mend

Please respond to the newsgroup,
so all can benefit.


One Day,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top