Class CompressedStream
Stream wrapper that compresses or decompresses data on the fly over a base stream, optionally applying checksum and encryption.
Inheritance
Inherited Members
Namespace: Telerik.Windows.Zip
Assembly: Telerik.Windows.Zip.dll
Syntax
public class CompressedStream : OperationStream, IDisposable
Constructors
CompressedStream(Stream, StreamOperationMode, CompressionSettings)
Creates a compression or decompression stream using the specified settings.
Declaration
public CompressedStream(Stream baseStream, StreamOperationMode mode, CompressionSettings settings)
Parameters
|
System.IO.Stream
baseStream
The base input/output stream. |
|
StreamOperationMode
mode
Stream operational mode. |
|
CompressionSettings
settings
Compression settings. |
Exceptions
|
System.ArgumentOutOfRangeException
Specified mode is not allowed for the given stream. |
CompressedStream(Stream, StreamOperationMode, CompressionSettings, Boolean, EncryptionSettingsBase)
Creates a compression or decompression stream with explicit checksum and encryption options.
Declaration
public CompressedStream(Stream baseStream, StreamOperationMode mode, CompressionSettings settings, bool useCrc32, EncryptionSettingsBase encryptionSettings)
Parameters
|
System.IO.Stream
baseStream
The base input/output stream. |
|
StreamOperationMode
mode
Stream operational mode. |
|
CompressionSettings
settings
Compression settings. |
|
System.Boolean
useCrc32
Indicates whether the CRC32 (true) or Adler32 (false) checksum algorithm will be used. |
|
EncryptionSettingsBase
encryptionSettings
Encryption settings. |
Exceptions
|
System.ArgumentOutOfRangeException
Specified mode is not allowed for the given stream. |
Properties
Checksum
Gets the running checksum (CRC32 or Adler32) accumulated from the first read/write until Flush.
Declaration
public long Checksum { get; }
Property Value
|
System.Int64
|
CompressedSize
Gets the total compressed byte count including any encryption header bytes.
Declaration
public long CompressedSize { get; }
Property Value
|
System.Int64
|
Methods
Dispose(Boolean)
Releases the unmanaged resources used by the Stream and optionally releases the managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
|
System.Boolean
disposing
Value which indicates whether both managed and unmanaged resources (true) on only unmanaged resources (false) should be released. |
Overrides
Read(Byte[], Int32, Int32)
Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
|
System.Byte[]
buffer
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 source. |
|
System.Int32
offset
The zero-based byte offset in buffer at which to begin storing the data read from the current stream. |
|
System.Int32
count
The maximum number of bytes to be read from the current stream. |
Returns
|
System.Int32
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. |
Overrides
Exceptions
|
System.NotSupportedException
The StreamOperationMode associated with
current OperationStream object does not match the underlying stream. |
|
System.ArgumentOutOfRangeException
The |
|
System.ArgumentException
The sum of the |
ReadAsync(Byte[], Int32, Int32, CancellationToken)
Reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.
Declaration
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Parameters
|
System.Byte[]
buffer
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 source. |
|
System.Int32
offset
The zero-based byte offset in buffer at which to begin storing the data read from the current stream. |
|
System.Int32
count
The maximum number of bytes to be read from the current stream. |
|
System.Threading.CancellationToken
cancellationToken
The token to monitor for cancellation requests. |
Returns
|
System.Threading.Tasks.Task<System.Int32>
A task returning the total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. |
Overrides
SetLength(Int64)
Sets the length of the current stream.
Declaration
public override void SetLength(long value)
Parameters
|
System.Int64
value
The desired length of the current stream in bytes. |
Overrides
Write(Byte[], Int32, Int32)
Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
|
System.Byte[]
buffer
An array of bytes. This method copies count bytes from buffer to the current stream. |
|
System.Int32
offset
The zero-based byte offset in buffer at which to begin copying bytes to the current stream. |
|
System.Int32
count
The number of bytes to be written to the current stream. |
Overrides
Events
ChecksumReady
Raised when checksum calculation completes for the processed data segment.
Declaration
public event EventHandler ChecksumReady
Event Type
|
System.EventHandler
|