Class RarArchiveLoadOptions

Class RarArchiveLoadOptions

Namespace: Aspose.Zip.Rar
Assembly: Aspose.Zip.dll (25.1.0)

使用于从压缩文件加载 Aspose.Zip.Rar.RarArchive 的选项。

public class RarArchiveLoadOptions

继承

objectRarArchiveLoadOptions

继承的成员

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

构造函数

RarArchiveLoadOptions()

public RarArchiveLoadOptions()

属性

DecryptionPassword

获取或设置用于解密条目和条目名称的密码。

public string DecryptionPassword { get; set; }

属性值

string

示例

您可以在提取归档时提供解密密码。

using (FileStream fs = File.OpenRead("encrypted_archive.rar"))
{
    using (var extracted = File.Create("extracted.bin"))
    {
        using (RarArchive archive = new RarArchive(fs, new ArchiveLoadOptions() { DecryptionPassword = "p@s$" }))
        {
            using (var decompressed = archive.Entries[0].Open())
            {
                byte[] b = new byte[8192];
                int bytesRead;
                while (0 < (bytesRead = decompressed.Read(b, 0, b.Length)))
                    extracted.Write(b, 0, bytesRead);

            }
        }
    }
}

另见

RarArchiveEntry.Open(string)

 中文