Covers topics on the Microsoft Certification Exam for the .NET Framework (Exam 70-536, Microsoft .NET Framework - Application Development Foundation)

Saturday, March 22, 2008

Which classes can be used to compress streams in the .NET Framework?

Stream compression is used to save space and save bandwidth. There are two primary classes used for compression/decompression, the GZipStream and the DeflateStream classes.

The first thing one might like to know is, which compression class to use? That depends on how you would like to use the data. If you will be writing the stream to a file, the GZipStream class includes additional headers that make it suitable for opening with the gzip tool. The DeflateStream class does not include headers and thus has a slightly smaller size at the expense of being less portable (which may not be a concern if the data never leaves the computer that is running the application)

Both compresson methods are based on industry standard algorithms that are free of patent protecton. This allows you to incorporate them into your application with out worrying about intellectual property concerns.

In later posts we will explore source code for compressing and decompressing streams, but it is important to note the compression size limits. (Which will be repeated each time compression is discussed)

GZipStream and DeflateStream classes can't compress files larger than 4GB


Additional Resources
System.IO.Compression.GZipStream
System.IO.Compression.DeflateStream
Using GZIP for compression in .NET

No comments:

Support This Site

LinkShare  Referral  Prg