我需要在 C# 中提取一个拆分的 rar 文件 (r00, r01, r02,...)。
我发现唯一可能有用的是sevenzipsharp。我找不到我正在尝试做的事情的例子。
有人说“ 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:\ziptest\test.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 日 *
我最终使用了这里提供的解决方案: Unrar an archive in C#
我修改了开关参数,使 WinRar 在后台运行,无需打开任何窗口。
如果有人确实想出了解决我的 SevenZipSharp 问题的方法,我仍然想知道,因为它是一个更“干净”的代码。