IOutputStream IOutputStream IOutputStream IOutputStream IOutputStream Interface


Represents a sequential stream of bytes to be written.

public : interface IOutputStream : IClosable
struct winrt::Windows::Storage::Streams::IOutputStream : IClosable
public interface IOutputStream : IDisposable
Public Interface IOutputStream Implements IDisposable
// You can't instantiate an interface directly in JavaScript. You can use objects that implement the interface, however.
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


Close Close Close Close Close

Releases system resources that are exposed by a Windows Runtime object.

.NET This interface appears as System.IDisposable.

C++/CX This interface appears as Platform::IDisposable.

(Inherited from IClosable)

FlushAsync() FlushAsync() FlushAsync() FlushAsync() FlushAsync()

Flushes data asynchronously in a sequential stream.

public : IAsyncOperation<Platform::Boolean> FlushAsync()
IAsyncOperation<bool> FlushAsync() const;
public IAsyncOperation<bool> FlushAsync()
Public Function FlushAsync() As IAsyncOperation( Of bool )
Windows.Storage.Streams.IOutputStream.flushAsync().done( /* Your success and error handlers */ );


The FlushAsync method may produce latencies and does not always guarantee durable and coherent storage of data. It's generally recommended to avoid this method if possible.

WriteAsync(IBuffer) WriteAsync(IBuffer) WriteAsync(IBuffer) WriteAsync(IBuffer) WriteAsync(IBuffer)

Writes data asynchronously in a sequential stream.

public : IAsyncOperationWithProgress<unsigned int, unsigned int> WriteAsync(IBuffer buffer)
IAsyncOperationWithProgress<uint32_t, uint32_t> WriteAsync(IBuffer buffer) const;
public IAsyncOperationWithProgress<uint, uint> WriteAsync(IBuffer buffer)
Public Function WriteAsync(buffer As IBuffer) As IAsyncOperationWithProgress( Of uint )( Of uint )
Windows.Storage.Streams.IOutputStream.writeAsync(buffer).done( /* Your success and error handlers */ );
IBuffer IBuffer IBuffer

A buffer that contains the data to be written.



Some stream implementations support queuing of write operations. In this case, the asynchronous execution of the WriteAsync method does not complete until the FlushAsync method has completed. For the buffer parameter, you don't have to implement the IBuffer interface. Instead, you can create an instance of the Buffer class or create a buffer by using methods in the CryptographicBuffer class.

Also consider writing a buffer into an IOutputStream by using the WriteBuffer method of the DataWriter class.