
Replacing a single line from a text file
Quote:
> Hello all,
> I want to replace a single line from a text file.
> I have the line number of which the text should be
> repleced. How to achieve this ?
> I am using StreamReader and StreamWriter classes.
You must copy the content before the line to the new file, then write the
new line and copy the content after the line.
Optimization, only possible if length of new and old line is equal: Store
the byte position within the file when reading so you can use binary access
and write the new line to the same position.
Armin