DotNetZip - Zip file manipulation in .NET languages

[Pages:1376]DotNetZip - Zip file manipulation in .NET languages

DotNetZip is a small, easy-to-use class library for manipulating .zip files. It can enable .NET applications written in , C#, or any .NET language, to easily create, read, and update zip files. Zip Compression is easy with DotNetZip. The DotNetZip project also includes a library for performing ZLIB, Deflate, or GZIP compression and decompression, a library for BZip2 compression and decompression, a GUI ZIP tool, and a few command line tools.

DotNetZip works on Windows-powered PCs with the full .NET Framework, and also runs on Windows Mobile devices that use the .NET Compact Framework. Create and read zip files in VB, C#, or any .NET language. The library can also be used from COM enironments, like PHP, Classivc ASP, or VBSCript. DotNetZip supports these scenarios:

creating a zip archive, adding files or directories into the archive listing files in an archive, extracting files from an archive modifying an existing archive - renaming entries, removing entries from an archive, or adding new entries to an archive creating zip files from stream content, saving to a stream, extracting to a stream, reading from a stream dynamically creating ZIP files from or Silverlight applications

If all you want is a better DeflateStream or GZipStream class to replace the one that is built-into the .NET BCL, that is here, too. DotNetZip's DeflateStream and GZipStream are available in a standalone assembly, based on a .NET port of Zlib. These streams

support compression levels and deliver much better performance that the built-in classes. There is also a ZlibStream to complete the set (RFC 1950, 1951, 1952).

This 100% managed code library can be used in any .NET application - Console, Winforms, WPF, , Sharepoint, Web services apps, Powershell scripts, and so on. It produces zip files that are fully interoperable with Windows Explorer, as well as Java applications, apps running on Linux.

It is designed to be simple and easy to use. DotNetZip is packaged as a single DLL, about 400k in size. It has no third-party dependencies. It is Medium Trust, so can be used on most hosters. Get zipping just by referencing the DLL. The library supports zip passwords, Unicode, ZIP64, stream input and output, AES encryption, multiple compression levels, self-extracting archives, and more.

The release includes the library, as well as some sample applications (with source) showing how to use the library.

DotNetZip is DonationWare

If you find DotNetZip useful, consider donating. I am now accepting donations on behalf of my favorite charity. and Yes, it is a real charity.

Example Usage

Example: creating a zip file

Copy

1 using (ZipFile zip = new ZipFile("MyZipFile.zip") 2{ 3 zip.AddFile("c:\\images\\personal\\7440-N49th.png" 4 zip.AddFile("c:\\Desktop\\2008-Regional-Sales-Report.pdf" 5 zip.AddFile("ReadMe.txt"); 6 zip.Save(); 7}

Tons more examples on Codeplex, and later in this helpfile.

Frequently Asked Questions

How does this Zip Library work? DotNetZip is packaged as a single DLL, a single assembly. It is fully managed code, written in C#, and provides support for reading and writing Zip archive files and streams. The main type is ZipFile, featuring methods like Add(), Extract() and Save(). There are string and int indexers for the entries of the ZipFile. There are properties for things like password protection, unicode and codepage support, and ZIP64 behavior. And there are progress events for Reading, Saving, and Extracting.

What do I need, in order to be able to create and read zip files from within my application using this library? To use the zip capability in your applications, you need to be using the .NET Framework 2.0 or later, and you need the DotNetZip assembly. You can use the Zip library from any application, whether a console application, a Windows-Forms application, a server-based application like an page, or something else. You can use C#, , , IronPython, IronRuby, F#, or any other .NET language.

What do I need to build this library from the source? To use the zip capability in your applications, you need to be using the .NET Framework 2.0 or later, and you need the DotNetZip assembly. You can use the Zip library from any application, whether a console application, a Windows-Forms application, a server-based application like an page, a smart-device app, a Windows Service, or something else. You can use C#, , , IronPython, IronRuby, F#, or any other .NET language. You can use the full version of Visual Studio, or one of the Visual Studio Express tools, or just a text editor.

What if I just want to use the graphical tool?

No problem. Just download the Utils download from the latest releases tab, and you will get an easy-to-use fully-functional ZIP creation and extraction tool, a free functional-equialent replacement for WinZip. It supports all the DotNetZip capability, like SFX, AES, ZIP64, arbitrary Code Pages, Unicode, zip comments, file and entry selection, and more.

What do I need to _build_ this library from the source?f You need the .NET Framework SDK v3.5, or later; or, Visual Studio 2008 or later. While the library is usable by .NET 2.0 and later, to build it you need .NET 3.5 or later. This is because the source code uses features that were introduced in the C# v3.0 compiler, vars and array initializers and so on. The .NET 3.5 SDK is available here. I don't know if the library will _build_ in Visual C# Express 2008; I never tried it. It should.

How big is the library? As of version 1.9, the Ionic zip DLL is about 420k in size. The selfextracting capability comprises about 200k of that. There is a "Reduced" build of the library in the Developer's Kit, that eliminates the SFX capability and results in a DLL of about half the size. The Compact-Framework version of the library is about 130k. There is just one DLL. There is no other pre-requisite.

Why would you want to produce yet another Zip Library? There are a number of options in the .NET world for manipulating zip files. Some are commercial libraries, some are open-source. You can even shoe-horn the System.IO.Packaging API, which is included in .NET 3.0, into a zip library. But there are tradeoffs for all of them. Some people are willing to give up commercial support for a lower price. Some people don't like the GPL. Some of those other packages are complex to use for zip files. Some of them don't have enough features (Eg, AES encryption, ZIP64). Some are too slow. What I

found is that most people want something simple and easy to use, that works well, has good features, compresses effectively and fast, and is the right price. DotNetZip is that option. It's fast, it's simple, it's free.

Does this library make self-extracting zip files? Yes. It can make self-extracting zip files or standard zip files. The self-extracting archives can either be Windows (GUI) apps or command-line applications. The self-extractors require .NET 2.0 on the computer doing the extraction.

Does this library read self-extracting zip files? Yes. As of v1.7, DotNetZip can read self-extracting zip files generated by WinZip. As of v1.8 (currently in preview), DotNetZip can read SFX archives generated by itself. DotNetZip does not (yet) read SFX archives built by some other tools. I've not tested it.

Are the zip files this library makes compatible with the java.util.zip classes in the Java class library? Yes. This library makes standard zip files. If you use some advanced features not supported by the built-in Java library, like AES encryption or ZIP64, then the zip files won't be readable by Java. This is a shortcoming in Java, not in DotNetZip.

If I create a zipfile with this library, can I open it from within a Java/PHP/Python/C/Perl application? From within WinRar/WinZIP? Yes. This library makes standard zip files, so anything that can read and write zip files, on any platform, can work with zipfiles generated from this library. In Java, you would use the java.util.zip library. In Python, you would use the zipfile module. Keep in mind that not all languages and environments support all ZIP features. For example, currently the Java library does not do ZIP64, and the zipfile module in Python does not support zipfile comments, while DotNetZip can create and read zip archives using those features. You need to be

careful with interop testing. If you don't know what these features are, you probably don't need them and you won't run into interop problems.

If I create a zipfile with a java/PHP/Python/C/Perl application, or with WinRar/WinZip/7zip, can I open it from within a .NET application, using this library? Yes. This library reads compliant zip files.

Can I use Windows Explorer to open the zip files that this library creates, and vice versa? Yes. This library reads and writes standard zip files. If you use extensions to the ZIP spec not supported by Windows, like ZIP64 or AES encryption, Windows Explorer will not be able to extract the files.

Does the library work with applications that depend on the .NET Compact Framework? Yes. DotNetZip is built for the .NET Compact Framework (v2.0 or later) as well as for the regular .NET Framework (v2.0 or later). This means you can build a Smart Device application in Visual Studio 2008, that uses the capabilities of DotNetZip.

Does the library support zero-length zip entries, zipfile comments, zip entry comments, zipping up empty directories, recursive directory traversal, zipping up selected files by filename (with wildcards), and password-protecting entries? Yes.

Does the library handle ZIP64? Yes. This was added in December 2008 in v1.7. The original ZIP specification allowed up to 65535 entries in a zip archive, and archive and entry sizes up to 4.2g. The ZIP64 extensions raise those restrictions, at the expense of compatibility and interoperability.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download