Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MemoryStream.CopyToAsync Method (Stream, Int32, CancellationToken)

.NET Framework (current version)
 

Asynchronously reads all the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.

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

public override Task CopyToAsync(
	Stream destination,
	int bufferSize,
	CancellationToken cancellationToken
)

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, in bytes, of the buffer. This value must be greater than zero.

cancellationToken
Type: System.Threading.CancellationToken

The token to monitor for cancellation requests.

Return Value

Type: System.Threading.Tasks.Task

A task that represents the asynchronous copy operation.

Exception Condition
ArgumentNullException

destination is null.

ArgumentOutOfRangeException

buffersize is negative or zero.

ObjectDisposedException

Either the current stream or the destination stream is disposed.

NotSupportedException

The current stream does not support reading, or the destination stream does not support writing.

Universal Windows Platform
Available since 10
.NET Framework
Available since 4.5
Return to top
Show:
© 2016 Microsoft