StreamCopyTo Method (Stream, Int32) |
Reads all the bytes from the current stream and writes them to a destination stream, using a specified buffer size.
Namespace: System.IOAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public void CopyTo(
Stream destination,
int bufferSize
)
Parameters
- destination
- Type: System.IOStream
The stream that will contain the contents of the current stream. - bufferSize
- Type: SystemInt32
The size of the buffer. This value must be greater than zero. The default size is 4096.
Exceptions Exception | Condition |
---|
ArgumentNullException | destination is null. |
ArgumentOutOfRangeException | bufferSize is negative or zero. |
NotSupportedException | The current stream does not support reading.-or-destination does not support writing. |
ObjectDisposedException | Either the current stream or destination were closed before the CopyTo(Stream) method was called. |
IOException | An I/O error occurred. |
See Also