阅读时我需要 Flush() 一个 FileStream 吗?
Do I need to Flush() a FileStream when reading?
我不确定从文件读取时是否也使用缓冲区,还是仅在写入文件时使用缓冲区。
Do I need to flush a FileStream() when reading?
没有。 Flush() 写入 写入缓冲区中的剩余字节。
is a buffer is also used when reading from a file?
是的,出于性能原因有一个缓冲区,但是没有办法刷新这个缓冲区,除了简单地从流中读取字节直到遇到 EOF。
这是 documentation 对 Stream.Flush() 说的话:
When overridden in a derived class, clears all buffers for this stream
and causes any buffered data to be written to the underlying device.
我想可以肯定地说,阅读时不需要冲洗。
我不确定从文件读取时是否也使用缓冲区,还是仅在写入文件时使用缓冲区。
Do I need to flush a FileStream() when reading?
没有。 Flush() 写入 写入缓冲区中的剩余字节。
is a buffer is also used when reading from a file?
是的,出于性能原因有一个缓冲区,但是没有办法刷新这个缓冲区,除了简单地从流中读取字节直到遇到 EOF。
这是 documentation 对 Stream.Flush() 说的话:
When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.
我想可以肯定地说,阅读时不需要冲洗。