Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does binarywriter.flush() also flush the underlying filestream object?

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?

like image 653
jacob sebastian Avatar asked Feb 25 '26 15:02

jacob sebastian


1 Answers

According to Reflector, BinaryWriter.Flush calls the Flush method of the underlying stream.

like image 51
dtb Avatar answered Feb 28 '26 06:02

dtb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!