Can streamreader change a file?

  • Thread starter Thread starter PSiegmann
  • Start date Start date
P

PSiegmann

Hello group,

if I open with streamreader a file to read in that way:

StreamReader sr = new StreamReader(c:\\test.txt,
System.Text.Encoding.GetEncoding(10000));

Is it possible that it can change the file in any way? (Change the
encoding of the actual file as example)
 
Hello group,

if I open with streamreader a file to read in that way:

StreamReader sr = new StreamReader(c:\\test.txt,
System.Text.Encoding.GetEncoding(10000));

Is it possible that it can change the file in any way? (Change the
encoding of the actual file as example)

To change the encoding of a file, rewrite it with new contents.

So, no, StreamReader cannot (by itself) change a file.
 
Lasse said:
To change the encoding of a file, rewrite it with new contents.

So, no, StreamReader cannot (by itself) change a file.

The only thing that should be changed by opening a file readonly is the last
accessed time.
 
if I open with streamreader a file to read in that way:

StreamReader sr = new StreamReader(c:\\test.txt,
System.Text.Encoding.GetEncoding(10000));

Is it possible that it can change the file in any way? (Change the
encoding of the actual file as example)

A StreamReader can not change the file itself (you can check the
methods).

If the file is opened in certain ways then other parts of the
app can change the file the StreamReader is reading.

Arne
 
Back
Top