我已經創建了一個使用FileStream的StreamReader。在StreamReader方法的末尾,使用Peek()方法時,我看到數字值爲65535.轉換爲char時表示句點'。'在VS中使用'watch',我可以看到EndOfStream已經到達。 65535('。')的值是什麼意思?它的ASCII碼對應的時間是('。')嗎?c# - 流讀取器結束顯示值65536('。')
我以爲我聽說'0'代表文件/流的結束。
注:如果流正在使用文件,我不確定EOF和EOS之間是否存在差異(流結束)。
//Contains some business logic, main focus is on the while loop expression
try
{
//The peek method is used to avoid moving the Stream's position.
//If we don't encounter a number character representing the RDW, keep reading until we find one.
while (!Char.IsDigit((char)this.StreamReader.Peek()))
{
if (!this.StreamReader.EndOfStream)
this.StreamReader.Read();
else
return false;
}
//Loop completed and found the next record without encountering the end of the stream
return true;
}
catch (IOException IOex)
{
throw new Exception(String.Format("An IO Exception occured when attempting to set the start position of the record.\n\n{0}", IOex.ToString()));
}
它看起來像某種溢出,可以張貼你如何閱讀流? – 2011-03-01 16:10:37