Writes a block of bytes to this stream using data from a buffer.
Assembly: mscorlib (in mscorlib.dll)
array is null.
offset and count describe an invalid range in array.
offset or count is negative.
An I/O error occurred.
- or -
Another thread may have caused an unexpected change in the position of the operating system's file handle.
The stream is closed.
The current stream instance does not support writing.
This method overrides Write.
The offset parameter gives the offset of the byte in array (the buffer index) at which to begin copying, and the count parameter gives the number of bytes that will be written to the stream. If the write operation is successful, the current position of the stream is advanced by the number of bytes written. If an exception occurs, the current position of the stream is unchanged.
Interrupting a thread that is performing a write operation is not supported. Although the operations may appear to be successful after the thread is unblocked, these actions can decrease your application's performance and reliability.
For a list of common I/O tasks, see Common I/O Tasks.
This code example is part of a larger example provided for the Lock method.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2