Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
[Visual Basic] Overridable Public Function Write( _ ByVal buffer() As Byte, _ ByVal offset As Integer, _ ByVal count As Integer _ ) As Integer [C#] public virtual int Write( byte[] buffer, int offset, int count ); [C++] public: virtual int Write( unsigned char* buffer[], int offset, int count ); [JScript] public function Write( buffer : Byte[], offset : int, count : int ) : int;
The total number of bytes written to the stream.
Exception Type | Condition |
---|---|
ArgumentException | The result of offset subtracted from the buffer length is less than count. |
ArgumentNullException | buffer is null. |
ArgumentOutOfRangeException | offset or count is negative. |
IOException | An I/O error occurs. |
NotSupportedException | The stream does not support writing. |
The default implementation calls the asynchronous BeginWrite method.
Implementations of this method copy count bytes to this stream from buffer beginning at offset. 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.
Use BinaryWriter for writing primitive data types.