ClassStreamExtensions
Extensions for the Stream class.
Definition
Namespace:Telerik.Windows.Zip.Utilities
Assembly:Telerik.Windows.Zip.dll
Syntax:
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
public static void CopyTo(this Stream source, Stream destination, TimeSpan? timeout)
Parameters
source
The stream from which the contents will be copied to another stream.
destination
The stream to which the contents of the current stream will be copied.
timeout
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
public static Task CopyToAsync(this Stream source, Stream destination, CancellationToken cancellationToken)
Parameters
source
destination
The stream to which the contents of the current stream will be copied.
cancellationToken
The token to monitor for cancellation requests.
Returns
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
public static byte[] ReadExactly(this Stream stream, byte[] buffer, int offset, int count)
Parameters
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
The byte offset in buffer at which to begin storing the data read from the current stream.
count
The number of bytes to be read from the current stream.
Returns
byte[]
Exceptions
buffer is null.
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.
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.