gpt4 book ai didi

C# - 流/文件流 EOF

转载 作者:太空狗 更新时间:2023-10-29 20:06:03 29 4
gpt4 key购买 nike

有没有人知道找到文件末尾的方法?我正在使用 BinaryReader 并尝试使用 PeekChar - 但它会引发异常。还有其他建议吗?

谢谢。

最佳答案

Stream 中,如果您 Read(buffer, offset, count) 您将得到一个非正结果,如果您 Peek() 你会得到一个否定的结果。

使用 BinaryReaderthe documentation建议 PeekChar() 应该返回负值:

Return Value

Type: System.Int32 The next available character, or -1 if no more characters are available or the stream does not support seeking.

你确定这不是一个损坏的流吗?即剩余的数据不能从给定的编码形成一个完整的 char

关于C# - 流/文件流 EOF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5016403/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com