Class
StreamExtensions

Extensions for the Stream class.

Definition

Namespace:Telerik.Windows.Zip.Utilities

Assembly:Telerik.Windows.Zip.dll

Syntax:

cs-api-definition
public static class StreamExtensions

Inheritance: objectStreamExtensions

Methods

CopyTo(Stream, Stream, TimeSpan?)

Reads the bytes from the current stream and writes them to another stream.

Declaration

cs-api-definition
public static void CopyTo(this Stream source, Stream destination, TimeSpan? timeout)

Parameters

source

Stream

The stream from which the contents will be copied to another stream.

destination

Stream

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

timeout

TimeSpan?

The time period after which the operation will be cancelled.

CopyToAsync(Stream, Stream, CancellationToken)

Asynchronously reads the bytes from the current stream and writes them to another stream. Both streams positions are advanced by the number of bytes copied.

Declaration

cs-api-definition
public static Task CopyToAsync(this Stream source, Stream destination, CancellationToken cancellationToken)

Parameters

source

Stream

destination

Stream

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

cancellationToken

CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous copy operation.

ReadExactly(Stream, byte[], int, int)

Reads count number of bytes from the current stream and advances the position within the stream.

Declaration

cs-api-definition
public static byte[] ReadExactly(this Stream stream, byte[] buffer, int offset, int count)

Parameters

stream

Stream

The stream to read from.

buffer

byte[]

An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current stream.

offset

int

The byte offset in buffer at which to begin storing the data read from the current stream.

count

int

The number of bytes to be read from the current stream.

Returns

byte[]

Exceptions

ArgumentNullException

buffer is null.

ArgumentOutOfRangeException

offset is outside the bounds of buffer. -or- count is negative. -or- The range specified by the combination of offset and count exceeds the length of buffer.

EndOfStreamException

The end of the stream is reached before reading count number of bytes.

Remarks

When count is 0 (zero), this read operation will be completed without waiting for available data in the stream.