提取拆分rar文件



我需要在C#中提取一个分离的rar文件(r00,r01,r02,…)。

我发现的唯一有用的东西是七巧玲珑。不过,我找不到一个我想做什么的例子。

有人说"文档可在https://archive.codeplex.com/?p=sevenzipsharp",但这并没有真正的帮助,因为我在那里找不到任何例子

我知道如果我使用不同的压缩格式,一切都会容易得多,但我不负责zip文件的生成,所以不幸的是,这不是一个选项。



*更新日期:2019年1月17日*

我试过了:

namespace test
{
class Program
{
static void Main(string[] args)
{
// Toggle between the x86 and x64 bit dll
var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
SevenZip.SevenZipBase.SetLibraryPath(path);
using (var file = new SevenZipExtractor(@"F:ziptesttest.part1.rar"))
{
file.ExtractArchive(@"F:dav");
}
}
}
}

但这给了我一个错误,当调用"ExtractArchive"时:

An unhandled exception of type 'SevenZip.SevenZipArchiveException' occurred in SevenZipSharp.dll
Additional information: Invalid archive: open/read error! Is it encrypted and a wrong password was provided?



*更新日期:2019年1月20日*

我最终使用了此处提供的解决方案:在C#中解压缩存档

我修改了开关参数,使WinRar在后台运行而不打开任何窗口。

如果有人真的为我的SevenZipSharp问题找到了解决方案,我仍然想知道,因为这是一个更"干净"的代码。

codeplex站点有一个讨论论坛,展示了几个github分支。我跟随一个来到这个样本:https://github.com/squid-box/SevenZipSharp/blob/dev/SevenZip.Tests/SevenZipExtractorTests.cs#L64这表明您只需要将第一个卷传递给SevenZipExtractor构造函数。

using (var extractor = new SevenZipExtractor(@"TestDatamultivolume.part0001.rar")) {
extractor.ExtractArchive(OutputDirectory);
}

最新更新