我有以下代碼:在哪裏使用StreamReader.DiscardBufferedData()?
StreamReader StreamReader = new StreamReader("File.txt");
string Line = "";
while((Line = StreamReader.ReadLine()) != null)
{
string Value = Line.Trim();
string Value2 = StreamReader.ReadLine();
int CursorValue = StreamReader.BaseStream.Position;
if(Condition)
{
StreamReader.BaseStream.Position = SOMETHING_ELSE;
Console.WriteLine(StreamReader.ReadLine());
}
StreamReader.BaseStream.Position = CursorValue;
}
可有人告訴我,我應該在這裏使用StreamReader.DiscardBufferedData()
?
的http://元。 stackexchange.com/questions/10647/how-do-i-write-a-good-title –
你想做什麼? [File.ReadAllText](http://msdn.microsoft.com/en-us/library/system.io.file.readalltext(v = vs.110).aspx)有什麼問題? –
如果他們僅在['DiscardBufferedData'](http://msdn.microsoft.com/zh-cn/library/system.io.streamreader.discardbuffereddata(v = vs.110))的文檔頁上給出了使用示例,的.aspx)。哦,等等,他們會。 –