Table of Contents

Method CopyToAsync

Namespace
KZDev.PerfUtils
Assembly
KZDev.PerfUtils.dll

CopyToAsync(Stream, int, CancellationToken)

Asynchronously reads all 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 Stream

The stream to which the contents of the current stream will be copied.

bufferSize int

The size, in bytes, of the buffer. This value must be greater than zero.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous copy operation.

Exceptions

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.