Zip compression feature introduce in .NET 4.5

Before introduction of zip compression feature in .NET framework 4.5 we have third party components like “DotnetZip” and other api like “SharpZip” for compressing and decompressing our file. In .Net 4.5 framework microsoft comes with the System.IO.Compression assembly that contain different types of compressing and decompressing files and stream.

For compressing and decompressing we have to add reference of “System.IO.Compression” and “System.IO.Compression.FileSystem” assembly in your project. We have following types to read and modify the contents of a compressed file ZipFile, ZipArchive, ZipArchiveEntry, DeflateStream, GZipStream

Currently .NET Framework supports two types of compression algorithms:

Deflate –>This is a very simple algorithm, used for simple compression and decompression operations. Don’t use this algorithm except if you intend to use compressed data only in your application because this algorithm is not compatible with any compression tool.

GZIP → This algorithm uses internally the Deflate algorithm. This algorithm includes a cyclic redundancy check value for detecting data corruption. Also it’s compatible with most compression tools because it writes headers to the compressed file, so compression tools -like WinZip and WinRAR- can easily access the compressed file and decompress it as well. This algorithm also can be extended to use other algorithms internally other than Deflate.

Deflate and GZIP can be found in the namespace System.IO.Compressionthat resides on assembly System.dll. This namespace contains only three types(ZipFile, ZipArchive, ZipArchiveEntry), the two algorithm implementation classes DeflateStreamand GzipStream both inherit directly from System.IO.Stream class.

About the Author

rsnegi

rsnegi

Related Posts

X