Stream::CopyTo Method (Stream^)

 

Reads the bytes from the current stream and writes them to another stream.

Namespace:   System.IO
Assembly:  mscorlib (in mscorlib.dll)

public:
void CopyTo(
	Stream^ destination
)

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.

No code example is currently available or this language may not be supported.

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
Return to top
Show: