binarywriter.flush() 是否也会刷新底层文件流对象?
我有一个代码片段如下:
Dim fstream = new filestream(some file here)
dim bwriter = new binarywriter(fstream)
while not end of file
read from source file
bwriter.write()
bwriter.flush()
end while
我的问题如下。当我调用 bwriter.flush() 时,它是否也会刷新 fstream 对象?或者我是否应该显式调用 fstream.flush() ,如以下示例所示:
while not end of file
read from source file
bwriter.write()
bwriter.flush()
fstream.flush()
end while
一些人建议我需要显式调用 fstream.flush() 以确保数据写入磁盘(或设备) )。但是,我的测试表明,只要我在 bwriter 对象上调用lush() 方法,数据就会写入磁盘。
有人可以证实这一点吗?
I have got a code snippet as follows:
Dim fstream = new filestream(some file here)
dim bwriter = new binarywriter(fstream)
while not end of file
read from source file
bwriter.write()
bwriter.flush()
end while
The question I have is the following. When I call bwriter.flush() does it also flush the fstream object? Or should I have to explicitly call fstream.flush() such as given in the following example:
while not end of file
read from source file
bwriter.write()
bwriter.flush()
fstream.flush()
end while
A few people suggested that I need to call fstream.flush() explicitly to make sure that the data is written to the disk (or the device). However, my testing shows that the data is written to the disk as soon as I call flush() method on the bwriter object.
Can some one confirm this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 Reflector, BinaryWriter.Flush 调用底层流的 Flush 方法。
According to Reflector, BinaryWriter.Flush calls the Flush method of the underlying stream.