E
Ernst Sauer
Hello,
I want (for example) to read a certain line again,
so I thought this should work:
StreamReader sr;
sr = new StreamReader(rfile)
string line;
long pos;
int i=0;
while (i++<3)
{ if (i==2) pos=sr.BaseStream.Position;
line=sr.ReadLine();
sr.DiscardBufferedData(); // no success with and witout
}
sr.BaseStream.Seek(pos, SeekOrigin.Begin);
I have a small test-file.
With the first ReadLine() sr reads the whole file
(later he splits the lines)
and sets the pos to the end of the stream.
With sr.DiscardBufferedData() I can't even read the second line.
Of course I can write my own method, but is this really necessary?
Thanks
E.S.
I want (for example) to read a certain line again,
so I thought this should work:
StreamReader sr;
sr = new StreamReader(rfile)
string line;
long pos;
int i=0;
while (i++<3)
{ if (i==2) pos=sr.BaseStream.Position;
line=sr.ReadLine();
sr.DiscardBufferedData(); // no success with and witout
}
sr.BaseStream.Seek(pos, SeekOrigin.Begin);
I have a small test-file.
With the first ReadLine() sr reads the whole file
(later he splits the lines)
and sets the pos to the end of the stream.
With sr.DiscardBufferedData() I can't even read the second line.
Of course I can write my own method, but is this really necessary?
Thanks
E.S.