System.IO.StreamWriter.Write Method

Writes a subarray of characters to the stream.

Syntax

public override void Write (char[] buffer, int index, int count)

Parameters

buffer
A character array that contains the data to write.
index
The character position in the buffer at which to start reading data.
count
The maximum number of characters to write.

Exceptions

TypeReason
ArgumentNullException buffer is null.
ArgumentExceptionbuffer.Length - index < count.
ArgumentOutOfRangeException index or count is negative.
ObjectDisposedExceptionThe current writer is closed.
NotSupportedException StreamWriter.AutoFlush is true or the System.IO.StreamWriter buffer is full, and the contents of the buffer cannot be written to the underlying fixed size stream because the System.IO.StreamWriter is at the end the stream.
System.IO.IOExceptionAn I/O error occurred.

Remarks

This method overrides TextWriter.Write(char).

The characters are read from buffer beginning at index and continuing through index + (count - 1). All characters are written to the underlying stream unless the end of the underlying stream is reached prematurely. StreamWriter.Flush is invoked automatically if StreamWriter.AutoFlush is true.

For a list of common I/O tasks, see Common I/O Tasks.

Requirements

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