Method CopyToAsync
CopyToAsync(Stream, int, CancellationToken)
Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.
public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
Parameters
destination
StreamThe stream to which the contents of the current stream will be copied.
bufferSize
intThe size, in bytes, of the buffer. This value must be greater than zero. The default size is 81920.
cancellationToken
CancellationToken The token to monitor for cancellation requests. The default value is None.
Returns
- Task
A task that represents the asynchronous copy operation.
Exceptions
- Argument
Null Exception destination
is null.- Argument
Out OfRange Exception buffersize
is negative or zero.- Object
Disposed Exception Either the current stream or the destination stream is disposed.
- Not
Supported Exception The current stream does not support reading, or the destination stream does not support writing.