NET通用提取器

引入 .NET 的 Universal Extractor

Universal Extractor for .NET 是一个插件,允许开发人员在各种格式中提取档案和压缩文件,包括 ZIP、RAR、7Z、Tar、GZIP 等。

支持的档案格式

.NET 的 Universal Extractor 支持各种档案格式,包括:

  • ZIP(ZIP)
  • 常见(RAR)
  • 7Z(7.7Z)
  • 特拉(TAR)
  • GZIP(.gz )
  • BZIP2(.bz2)

提取档案

要使用 Universal Extractor for .NET 提取存档,您可以使用以下代码示例:

using System.IO;
using Aspose.Zip;

// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"))
{
    // Extract the archive to a directory
    archive.ExtractToDirectory("extracted");
}

这个代码提取了内容的 example.zip 到一个名为目录的档案 extracted.

提取档案与密码保护

如果存档是密码保护,您可以使用以下代码示例提取它:

using System.IO;
using Aspose.Zip;

// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"), new ArchiveLoadOptions() { DecryptionPassword = "YOUR-PASSWORD" })
{
    // Extract the archive to a directory
    archive.ExtractToDirectory("extracted");
}

这个代码提取了内容的 example.zip 存档,以密码保护,到一个名为 extracted.

档案内容列表

要列出未提取档案的内容,您可以使用以下代码示例:

using System.IO;
using Aspose.Zip;

// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"))
{
    // Get the entries in the archive
    var entries = archive.Entries;

    // Iterate over the entries and print their names
    foreach (var entry in entries)
    {
        Console.WriteLine(entry.Name);
    }
}

此代码列出内容的内容 example.zip 存档,没有提取。

 中文