OverWrite a line of text?

  • Thread starter Thread starter Eric B.
  • Start date Start date
E

Eric B.

I coulda sworn it was possible to overwrite specific lines in a text file
without disturbing the rest, or was that in C++?

Will a TextWriter object do this?

Eric B.
 
I coulda sworn it was possible to overwrite specific lines in a text file
without disturbing the rest, or was that in C++?

Will a TextWriter object do this?

Is the new line of text *exactly* the same size (in bytes, after
encoding) as the old line? If so, it's possible. It not, it's not. You
can't just arbitrarily insert and delete data from the middle of
files.

Jon
 
You could script edlin to change a line. That brings back memories! Under
the hood I'm sure it's not different then the following:

string [] lines = File.ReadAllLines("somefile.txt");
lines [someline] = "a new line";
File.WriteAllLines ("somefile.txt", lines);
 

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

Back
Top