StreamExtensions
Extensions for the Stream class.
Definition
Namespace:Telerik.Windows.Zip.Utilities
Assembly:Telerik.Windows.Zip.dll
Syntax:
public static class StreamExtensions
Inheritance: objectStreamExtensions
Methods
Reads the bytes from the current stream and writes them to another stream.
public static void CopyTo(this Stream source, Stream destination, TimeSpan? timeout)
The stream from which the contents will be copied to another stream.
destinationStreamThe stream to which the contents of the current stream will be copied.
timeoutTimeSpan?The time period after which the operation will be cancelled.
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.
public static Task CopyToAsync(this Stream source, Stream destination, CancellationToken cancellationToken)
The stream to which the contents of the current stream will be copied.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns:A task that represents the asynchronous copy operation.
Reads count number of bytes from the current stream and advances the position within the stream.
public static byte[] ReadExactly(this Stream stream, byte[] buffer, int offset, int count)
The stream to read from.
bufferbyte[]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.
The byte offset in buffer at which to begin storing the data read from the current stream.
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.
When count is 0 (zero), this read operation will be completed without waiting for available data in the stream.