The Xceed.Compression namespace defines the CompressedStream class which can be constructed around any kind of .NET Stream to compress data that is written to the stream and decompress data that is read from the stream. It also defines the QuickCompression class which exposes static methods that allow quick and easy compression and decompression of byte arrays.
The following diagram represents the relationship between the CompressedStream and the Stream classes:
The CompressedStream class is a pass-through stream that applies compression and decompression to any type of inner stream, for example a FileStream, MemoryStream, etc.
The CompressedStream class can compress and decompress data using the compression methods specified in the CompressionMethod enumeration.
The class applies what is called raw or naked compression. Meaning that no formatting, overall error checking and identifying information is written or read to and from the compressed data. The implication is that it is not possible to identify the type of compressed data just from reading it. Nor is it possible to establish with absolute certainty that the data is valid once decompressed.
As best practice, use the CompressedStream class if the compressed data is going to be made part of a container format. A format that can identity or specifies by design the compression method used and other meta data. For example, Xceed Zip for .NET uses the CompressedStream class. There, the zip file format provides a place to store the compression method, computes CRCs to validate data and stores other useful meta information about the data being compressed.
If those conditions aren't met, it is better to use the formatted compressed stream classes.
Keep in mind that once a CompressedStream class is created around a stream, it becomes the owner of the stream and both streams will be closed when the CompressedStream is closed. To bypass this behavior, you can set the Transient property of the CompressedStream class to true. This will prevent the inner stream from being closed along with it.
The QuickCompression class exposes static methods that allow quick and easy compression and decompression of byte arrays. The QuickCompression class does not provide as much flexibility as the CompressedStream class. In cases where more complex operations, such as streaming, are required, developers will need to use the CompressedStream class.