OverWrite a line of text?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric B.

    OverWrite a line of text?

    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.

  • Jon Skeet [C# MVP]

    #2
    Re: OverWrite a line of text?

    On Oct 16, 8:02 am, "Eric B." <bigb...@sesame street.comwrote :
    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

    Comment

    • Family Tree Mike

      #3
      Re: OverWrite a line of text?

      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.ReadAllLin es("somefile.tx t");
      lines [someline] = "a new line";
      File.WriteAllLi nes ("somefile.txt" , lines);


      "Eric B." <bigbird@sesame street.comwrote in message
      news:DDD9EA49-E64F-4B50-B8AC-B424441F94CF@mi crosoft.com...
      >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.

      Comment

      Working...