Stream.CopyTo Method (Stream, Int32)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Reads all the bytes from the current stream and writes them to a destination stream, using a specified buffer size.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- destination
- Type: System.IO.Stream
The stream that will contain the contents of the current stream.
- bufferSize
- Type: System.Int32
The size of the buffer. This value must be greater than zero. The default size is 4096.
| 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 method was called. |
| IOException | An I/O error occurred. |