![]() |
VOOZH | about |
dotnet add package Cube.FileSystem.SevenZip --version 8.4.1
NuGet\Install-Package Cube.FileSystem.SevenZip -Version 8.4.1
<PackageReference Include="Cube.FileSystem.SevenZip" Version="8.4.1" />
<PackageVersion Include="Cube.FileSystem.SevenZip" Version="8.4.1" />Directory.Packages.props
<PackageReference Include="Cube.FileSystem.SevenZip" />Project file
paket add Cube.FileSystem.SevenZip --version 8.4.1
#r "nuget: Cube.FileSystem.SevenZip, 8.4.1"
#:package Cube.FileSystem.SevenZip@8.4.1
#addin nuget:?package=Cube.FileSystem.SevenZip&version=8.4.1Install as a Cake Addin
#tool nuget:?package=Cube.FileSystem.SevenZip&version=8.4.1Install as a Cake Tool
👁 Package
👁 AppVeyor
👁 Codecov
Cube.FileSystem.SevenZip is a wrapper library of the 7-Zip via COM interface. The project also has an application for compressing or extracting archives, which name is CubeICE. Libraries and applications are available for .NET Framework 3.5, 4.5 or later. Note that some projects are licensed under the GNU LGPLv3 and the others under the Apache 2.0. See License.md for more information.
You can install the library through the NuGet package. Add dependencies in your project file or select it from the NuGet packages UI on Visual Studio.
A simple example for archiving files is as follows. Note that the statement "using Cube.FileSystem.SevenZip;" has been omitted in all samples.
// Set only what you need.
var files = new[] { ".DS_Store", "Thumbs.db", "__MACOSX", "desktop.ini" };
var options = new CompressionOption
{
CompressionLevel = CompressionLevel.Ultra,
CompressionMethod = CompressionMethod.Lzma,
EncryptionMethod = EncryptionMethod.Aes256,
Password = "password",
Filter = Filter.From(files),
CodePage = CodePage.Utf8,
};
using (var writer = new ArchiveWriter(Format.Zip, options))
{
writer.Add(@"path\to\file");
writer.Add(@"path\to\directory_including_files");
var progress = new Progress<Report>(e => DoSomething(e));
writer.Save(@"path\to\save.zip", progress);
}
You create an ArchiveWriter object with an archiving format (e.g. Zip, SevenZip, ...), add files and/or directories you want to archive, set some additional options, and finally call the Save method. When you create Tar based archives, you can use a TarOption object for selecting a compression method.
var options = new CompressionOption
{
CompressionLevel = CompressionLevel.Ultra,
CompressionMethod = CompressionMethod.BZip2, // GZip, BZip2, XZ or Copy
};
using (var writer = new ArchiveWriter(Format.Tar, options))
{
writer.Add(@"path\to\file");
writer.Add(@"path\to\directory_including_files");
writer.Save(@"path\to\save.tar.gz");
}
If you want to extract all files from the archive, you create an ArchiveReader object and call the Extract method. The 2nd argument of the constructor, that means the password of the archive, can be set string or Cube.Query<string> object. The latter is mainly used for implementing the interactive mode.
// Set password directly or using Query<string>
var password = new Cube.Query<string>(e =>
{
e.Result = "password";
e.Cancel = false;
});
// Supports only the Filter property
var files = new[] { ".DS_Store", "Thumbs.db", "__MACOSX", "desktop.ini" };
var options = new ArchiveOption { Filter = Filter.From(files) };
using (var reader = new ArchiveReader(@"path\to\archive", password, options))
{
var progress = new Progress<Report>(e => DoSomething(e));
reader.Save(@"path\to\directory", progress);
}
Note that ArchiveWriter and ArchiveReader classes need to execute in the same thread from constructing to destroying. Use Task.Run() in the whole transaction if you need to archive or extract files asynchronously.
Copyright © 2010 CubeSoft, Inc. See License.md for more information.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net35 net35 is compatible. net40 net40 was computed. net403 net403 was computed. net45 net45 was computed. net451 net451 was computed. net452 net452 was computed. net46 net46 is compatible. net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.4.1 | 678 | 5/29/2024 |
| 7.0.0 | 1,203 | 7/21/2022 |
| 6.0.1 | 1,132 | 3/1/2022 |
| 6.0.0 | 1,124 | 1/24/2022 |
| 5.0.0 | 1,089 | 10/26/2021 |
| 1.15.10 | 1,250 | 6/15/2020 |
| 1.15.0 | 1,480 | 4/22/2019 |
| 1.14.0 | 1,398 | 2/17/2019 |
| 1.13.0 | 1,496 | 11/22/2018 |
| 1.12.0 | 1,511 | 10/23/2018 |
| 1.11.1 | 1,498 | 10/17/2018 |
| 1.11.0 | 1,519 | 10/17/2018 |