Project DescriptionA managed 7-zip library written in C# which provides data (self-)extraction and compression (all 7-zip formats are supported). It wraps 7z.dll or any compatible one and makes use of LZMA SDK.
Recent announcements:I received some donations and about to continue development. Thanks for your support. I will try hard to make SevenZipSharp even better.
I developed a complete managed 7-zip implementation. If you are not able to use SevenZipSharp due to COM restriction of your ASP.NET server, this is your last chance. If interested, contact me via CodePlex.
GeneralSevenZipSharp is an open source wrapper for
7-zip released under
LGPL v3.0. It exploits the native 7zip dynamic link library through its COM interface and exports classes to work with various file archives. The project appeared as an improvement of
http://www.codeproject.com/KB/DLL/cs_interface_7zip.aspx.
It consists of 4 parts: SevenZipSharp library itself, console and GUI test applications and documentation. All are built with Microsoft Visual Studio 2008 and under .NET 2.0.
In order to build the documentation, you must have
Sandcastle and
DocProject installed.
SevenZipSharp uses
Microsoft FxCop to maintain the conformance of the code to C# standarts, FxCop project is included.
Check SVN for the latest version of SevenZipSharp.
Quick startSevenZipSharp exports three main classes - SevenZipExtractor, SevenZipCompressor and SevenZipSfx.
SevenZipExtractor is a 7-zip unpack front-end, it allows either to extract archives or LZMA-compressed byte arrays.
SevenZipCompressor is a 7-zip pack front-end, it allows either to compress archives or byte arrays.
SevenZipSfx is the special class to create self-extracting archives. It uses the embedded
sfx module by Oleg Scherbakov .
LzmaEncodeStream/LzmaDecodeStream are special fully managed classes derived from Stream to store data compressed with LZMA and extract it.
See SevenZipTest/Program.cs for simple code examples; SevenZipTestForms is the GUI demo application.
You may find useful the SevenZipSharp documentation provided in CHM format. On Windows XP SP2 or later or Vista unblock the file to view it correctly.
Native librariesSevenZipSharp requires a 7-zip native library to function. You can specify the path to a 7-zip dll (7z.dll, 7za.dll, etc.) in LibraryManager.cs at compile time, your app.config or via SetLibraryPath() method at runtime. <Path to SevenZipSharp.dll> + "7z.dll" is the default path. For 64-bit systems, you must use the 64-bit versions of those libraries.
7-zip ships with 7z.dll, which is used for all archive operations (usually it is "Program Files\7-Zip\7z.dll"). 7za.dll is a light version of 7z.dll, it supports only 7zip archives. You may even build your own library with formats you want from 7-zip sources. SevenZipSharp will work with them all.
Main features
- Encryption and passwords are supported.
- Since the 0.26 release, archive properties are supported.
- Since the 0.28 release, multi-threading is supported.
- Since the 0.29 release, streaming is supported.
- Since the 0.41 release, you can specify the compression level and method.
- Since the 0.50 release, archive volumes are supported.
- Since the 0.51 release, archive updates are supported (0.52 - ModifyArchive). You must use the most recent 7z.dll (v9.04) for this feature.
Extraction is supported from any archive format in InArchiveFormat - such as 7-zip itself, zip, rar or cab and the format is automatically guessed by the archive signature (since the 0.43 release).
You can compress streams, files or whole directories in OutArchiveFormat - 7-zip, Xz, Zip, GZip, BZip2 and Tar.
Please note that GZip and BZip2 compresses only one file at a tme.Self-extracting archivesSevenZipSfx appeared in the 0.42 release. It supports custom sfx modules. The most powerful one is embedded in the assembly, the other lie in SevenZip/sfx directory. Apart from usual sfx, you can make even small installations with the help of SfxSettings scenarios. Refer to the
"configuration file parameters" for the complete command list.
Advanced work with SevenZipCompressorSevenZipCompressor.CustomParameters is a special property to set compression switches, compatible with command line switches of 7z.exe. The complete list of those switches is in 7-zip.chm of 7-Zip installation. For example, to turn on multi-threaded compression, code
<SevenZipCompressor Instance>.CustomParameters.Add("mt", "on");
For the complete switches list, refer to 7-zip.chm in the 7-zip installation.
Conditional compilation symbolsSince the 0.50 release, compilation symbols are supported: UNMANAGED, COMPRESS, SFX, LZMA_STREAM.
- UNMANAGED allows the main COM part of SevenZipSharp to be built.
- COMPRESS allows the compression classes to be built.
- SFX allows the sfx classes to be built.
- LZMA_STREAM allows LzmaEncodeStream/LzmaDecodeStream to be built.
