BufferedStream.Flush Method ()


Clears all buffers for this stream and causes any buffered data to be written to the underlying device.

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)

override Flush : unit -> unit

Exception Condition

The stream has been disposed.


The data source or repository is not open.

Flushing the stream will not flush its underlying encoder unless you explicitly call Flush or Close.

If you use the BufferedStream constructor, thus specifying the buffer size while creating the BufferedStream object, the content is flushed when it reaches the buffer size. For example, code such as BufferedStream bs = new BufferedStream(bs, 5) will flush the content when the buffer size reaches 5 bytes.

All the read and write methods of BufferedStream automatically maintain the buffer, so there is no need to invoke Flush when switching back and forth between reading and writing.

This code example is part of a larger example provided for the BufferedStream class.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top