Stream::CopyTo Method (Stream^, Int32)
.NET Framework (current version)
Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- destination
-
Type:
System.IO::Stream^
The stream to which the contents of the current stream will be copied.
- bufferSize
-
Type:
System::Int32
The size of the buffer. This value must be greater than zero. The default size is 81920.
| 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. |
Copying begins at the current position in the current stream, and does not reset the position of the destination stream after the copy operation is complete.
Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Show: