我想从给定的.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
});
}
但是无论密码正确与否,它都会提取损坏的文件。