System.IO.Stream.Write Method

When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.


public abstract void Write (byte[] buffer, int offset, int count)


An array of bytes. This method copies count bytes from buffer to the current stream.
The zero-based byte offset in buffer at which to begin copying bytes to the current stream.
The number of bytes to be written to the current stream.


ArgumentException(offset + count ) is greater than the length of buffer.
ArgumentNullException buffer is null.
ArgumentOutOfRangeException offset or count is negative.
System.IO.IOExceptionAn I/O error occurred.
NotSupportedExceptionThe stream does not support writing.
ObjectDisposedExceptionThe stream is closed.


Use the Stream.CanWrite property to determine whether the current instance supports writing. Use the Stream.WriteAsync(Byte[], int, int) method to write asynchronously to the current stream.

If the write operation is successful, the position within the stream advances by the number of bytes written. If an exception occurs, the position within the stream remains unchanged.


Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,