[]
Decompresses data from .NET streams.
public class C1ZStreamReader : Stream, IDisposable, IAsyncDisposable
To decompress data from a compressed stream, create a C1ZStreamReader object passing the compressed stream to the C1ZStreamReader constructor.
Then read the data from the C1ZStreamReader using the Read(byte[], int, int) method, or create a StreamReader on the C1ZStreamReader. The second option is indicated when you want to read formatted data.
The code below decompresses a string that was stored into a memory stream object:
public string ExpandString(byte[] buffer)
{
// turn buffer into a memory stream
var ms = new MemoryStream(buffer);
// attach decompressor stream to memory stream
var sr = new C1ZStreamReader(ms);
// read uncompressed data
var reader = new StreamReader(sr);
return reader.ReadToEnd();
}
Name | Description |
---|---|
C1ZStreamReader(Stream) | Initializes a new instance of the C1ZStreamReader class. |
C1ZStreamReader(Stream, bool) | Initializes a new instance of the C1ZStreamReader class. |
C1ZStreamReader(Stream, bool, bool) | Initializes a new instance of the C1ZStreamReader class. |
C1ZStreamReader(Stream, bool, int) | Initializes a new instance of the C1ZStreamReader class. |
C1ZStreamReader(Stream, bool, int, int) | Initializes a new instance of the C1ZStreamReader class. |
C1ZStreamReader(Stream, bool, long, int) | Initializes a new instance of the C1ZStreamReader class. |
Name | Description |
---|---|
BaseStream | Gets the underlying stream that contains the compressed data. |
CanRead | Always returns True. |
CanSeek | Always returns False. |
CanWrite | Always returns False. |
Length | Gets the length of the compressed stream if it is known (or -1 if the length of the compressed stream is unknown). |
OwnsBaseStream | Gets or sets whether calling the Close() method will also close the underlying stream (see BaseStream). |
Position | Gets the position within the stream (read-only). |
SizeCompressed | Gets the number of bytes in the stream (compressed bytes). |
SizeCompressedLong | Gets the number of bytes in the stream (compressed bytes). |
SizeUncompressed | Gets the number of bytes that were compressed into the stream (uncompressed bytes). |
SizeUncompressedLong | Gets the number of bytes that were compressed into the stream (uncompressed bytes). |
ZStream | Gets the ZStream instance wrapped by this C1ZStreamWriter. |
Name | Description |
---|---|
Close() | Closes the current stream compressor and flushed any pending data into the base stream. If the OwnsBaseStream property is set to True (the default value), then this method also closes the base stream and releases any resources (such as sockets and file handles) associated with it. |
Flush() | Clears all buffers for this stream and causes any buffered data to be written to the underlying stream. |
Read(byte[], int, int) | Reads a sequence of bytes from the underlying compressed stream, decompressing them into a buffer, then advances the position within the stream by the number of bytes read. |
ReadByte() | Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. |
Seek(long, SeekOrigin) | Not supported. |
SetLength(long) | Sets the number of compressed bytes to read from the underlying stream. |
Write(byte[], int, int) | This method is overridden and is not supported by the C1ZStreamReader class. |