我想从给定的 .rar 存档中提取文件,该存档受密码保护。我有以下内容:
pwd = "password";
srs = @"c:\path\file.rar"
des = @"c:\path\folder"
using (var archive = RarArchive.Open(srs, new ReaderOptions() { Password = pwd }))
{
foreach (var entry in archive.Entries)
{
entry.WriteToDirectory(des, new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true
});
}
但它会在密码正确和错误时提取损坏的文件。