Stream::CopyTo Method (Stream^)
Reads the bytes from the current stream and writes them to another stream.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- destination
-
Type:
System.IO::Stream^
The stream to which the contents of the current stream will be copied.
| Exception | Condition |
|---|---|
| ArgumentNullException | destination is null. |
| 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.
The following example copies the contents of a FileStream to a MemoryStream.
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