I know there are libraries out there for working with ZIP files. And, you can alternatively use the functionality built into Windows for working ZIP files.
But, I'm wondering if anyone has worked out how to use the tools built into the System.IO.Compression namespace within .NET for reading/writing ZIP files? Or, is it not possible using only this namespace?
UPDATED: I've seem someone comment that the System.IO.Packaging namespace might be usefull with this also. Does anyone know exactly how to do it?
ZipFile.Open Method (System.IO.Compression)Opens a zip archive at the specified path and in the specified mode.
The most important difference is that gzip is only capable to compress a single file while zip compresses multiple files one by one and archives them into one single file afterwards. Thus, gzip comes along with tar most of the time (there are other possibilities, though). This comes along with some (dis)advantages.
Folders that are compressed using the Compressed (zipped) Folders feature use less drive space and can be transferred to other computers more quickly. You can work with a compressed folder and the files or programs it contains just as you would an uncompressed folder.
MSDN has a complete example http://msdn.microsoft.com/en-us/library/system.io.packaging.zippackage.aspx using the ZipPackage class. Requires .NET 3.5.
Dave, very nice!! I didn't know that was in there.
Now that I know what to look for, I was able to find an article with a small code sample on how to use it: http://weblogs.asp.net/jgalloway/archive/2007/10/25/creating-zip-archives-in-net-without-an-external-library-like-sharpziplib.aspx
On a related note, I also found the DotNetZip project that looks extremely easy to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With