BuildMaster SDK Reference
Version:

CopyToAsync(System.IO.Stream source, System.IO.Stream destination, int bufferSize, System.Threading.CancellationToken cancellationToken, System.Action<long> reportProgress) Method

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

Syntax

public static System.Threading.Tasks.Task CopyToAsync(System.IO.Stream source, System.IO.Stream destination, int bufferSize, System.Threading.CancellationToken cancellationToken, Action<long> reportProgress)

Parameters

source
Type: System.IO.Stream

The stream to copy from.

destination
Type: System.IO.Stream

The stream to copy to.

bufferSize
Type: int

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

cancellationToken
Type: System.Threading.CancellationToken

The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None.

reportProgress
Type: System.Action<long>

Delegate which will be invoked periodically with the number of bytes copied so far as its argument.

Returns

A task that represents the asynchronous copy operation.

Exceptions

System.ArgumentNullException

source is null (Nothing in Visual Basic) or destination is null (Nothing in Visual Basic).

System.ArgumentOutOfRangeException

bufferSize is negative or zero.

System.ObjectDisposedException

Either the source stream or the destination stream is disposed.

System.NotSupportedException

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