We had been depending upon third party libraries when we
were requiring compressing files before release of .NET Framework 2.0. But now
we have native libraries in .NET Framework 2.0. DeflateStream
and GZipStream are new base
class libraries in .NET Framework 2.0 under namespace System.IO.Compression
in System assembly.
|
DeflateStream
|
Provides functions and properties to compress and
decompress streams using the Deflate algorithm
|
|
GZipStream
|
Provides functions and properties to compress and decompress
streams using gzip algorithm
|
DEFLATE compression is the patent free algorithm which is a
combination of Lempel-Ziv (LZ77) and Huffman compression methods. Deflate
algorithm is implemented in DeflateStream class. You can get more details about
Deflate algorithm in IETF's RFC 1951.
GZip is short form of GNU Zip. It is based
on the DEFLATE algorithm having similar basic functionality.
Similarities in DeflateStream and GZipStream
·
Both classes have almost similar basic logic of algorithm.
·
Implementation techniques for both classes are very similar in
.Net 2005.
·
These classes are normally used to compress
single file at a time. For multiple file compression we need to assemble
collection of files in a tar archive before applying
GZip. We can also apply concatenation of streams of multiple files to achieve
that using GZip only.
Difference between DeflateStream and GZipStream
·
In GZipStream, Cyclic Redundancy Check (CRC) has been included to
detect the data corruption. It makes GZipStream more
reliable than DeflateStream. But due to this overhead, GZipStream always
creates a larger file after compression compared to DeflateStream.