我已经创建了一个使用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