Yes and no. Your question is a little more complicated then just reading
and writing lines.
You can certainly open a FileStream with read/write permissions. However,
streams work on bytes, not lines. Now, you can create a StreamReader or
StreamWriter from a file stream, but these are mutually exclusive meaning
that you cannot read and write at the same time. You can normally chain the
readers and writers, but I do not know how that would behave if you pointed
them to the same stream (normally it is used to copy the contents).
What you might try doing is to read the lines in and copy them to a
temporary file, changing the lines that you want. Then writing that file
onto the original.
Or, if you are not shy of using bytes, you could work with the FileStream
directly and determine where line 500 begins and end and overwrite it, but
you can run into problems if the byte count of what you are writing is not
the same as what you are replacing.
"VM" <vo******@yahoo .com> wrote in message
news:O4******** ******@TK2MSFTN GP11.phx.gbl...
Is it possible to open an ascii file, read the first 499 lines, overwrite
line 500 with the new string, and close the file? All the lines before and
after line 500 will be untouched.
Thanks.