Table of Contents

CopyStreamAsync Method

Definition

Namespace
Cuemon.IO
Assemblies
Cuemon.IO.dll
Source
src/Cuemon.IO/Extensions/StreamDecoratorExtensions.cs

CopyStreamAsync(IDecorator<Stream>, Stream, int, bool, CancellationToken)

Asynchronously reads the bytes from the enclosed Stream of the specified decorator and writes them to the destination.

public static Task CopyStreamAsync(this IDecorator<Stream> decorator, Stream destination, int bufferSize = 81920, bool changePosition = true, CancellationToken ct = default)

Parameters

decorator IDecorator<Stream>

The IDecorator<T> to extend.

destination Stream

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

bufferSize int

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

changePosition bool

if true, the enclosed Stream of the specified decorator will temporarily have its position changed to 0; otherwise the position is left untouched.

ct CancellationToken

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

Returns

Task

Exceptions

ArgumentNullException

decorator cannot be null.