Mono Class Library: System.IO.MemoryStream Overview | Members

System.IO.MemoryStream.Write Method

Writes a block of bytes to the current stream at the current position using data read from buffer. [Edit]

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

Parameters

buffer
The byte array to write data from. [Edit]
offset
A int that specifies the zero based byte offset into buffer at which to begin writing from. [Edit]
count
A int that specifies the maximum number of bytes to write from buffer. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionbuffer is null. [Edit]
NotSupportedException

The current stream does not support writing.

-or-

The current position is closer than count bytes to the end of the stream, and the capacity cannot be modified.

[Edit]
ArgumentException(offset + count ) is greater than the length of buffer. [Edit]
ArgumentOutOfRangeExceptionoffset or count are negative. [Edit]
System.IO.IOExceptionAn I/O error occurred. [Edit]
ObjectDisposedExceptionThe current stream is closed. [Edit]

Remarks

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

If the write takes place immediately following a seek beyond the end of the stream, that stream is zero-byte-extended to the new seek position before the given bytes are written.

Write operations at the end of a resizable System.IO.MemoryStream expand the System.IO.MemoryStream.

Note: Use the MemoryStream.CanWrite method to determine whether the current stream supports writing.

Note: This method overrides Stream.Write(Byte[], int, int).

[Edit]

Requirements

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