BT

Microsoft .NET Finally Offers a General Purpose Zip Library

by Jonathan Allen on May 23, 2012 |

The .NET Framework has always had a weird relationship with the Zip file format. From the very beginning .NET actually did support Zip files, but in a way most people didn’t realize. The long since abandoned J# programming language included Java’s java.util.zip package. In a 2003 article by Ianier Munoz, one can see how to use J# Zip libraries in C#.

.NET 2.0 was very much a step backwards in this area. By then J# was already largely forgotten by the developer community and instead we were offered the nearly useless IO.Compression namespace. The DeflateStream and GZipStream classes only offered single pass, stream-based compression. Furthermore they lack the ability to handle the metadata associated with multiple file archives such as Zip.

In 2006 Microsoft offered an uncharacteristically clumsy API for Zip files via the ZipPackage class. This API was created mainly to support the Open XML Paper Specification (XPS). The XPS was originally seen as an attempt to compete directly with Adobe’s PDF file format, but those efforts have been largely abandoned. Today XPS is used for the Windows print spooler, replacing the GDI-based WinPrint if the printer supports it.

For .NET 4.5 we are finally seeing a built-in API for Zip files worth looking at. While it is still too soon to tell if the ZipArchive class is a real competitor to libraries such as DotNetZip, it at least offers something usable to those who are unable to use open source libraries due to licensing issues. Tugberk Ugurlu has a walkthrough showing how to use ZipArchive in .NET 4.5.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT