从 RAR 存档中提取文件

Extracting files from RAR archive

我正在尝试从 Rar 中提取文件,但我收到消息

"Cannot use Archive random access on SOLID Rar files"

string[] filePaths = Directory.GetFiles(@"C:\Users\Luka\Desktop\RarFiles\", "*.rar",
                                    SearchOption.TopDirectoryOnly);


foreach (var item in filePaths)
{
    var archive = ArchiveFactory.Open(item);//@"C:\test.rar"Monitoring

    foreach (var entry in archive.Entries.Where(x=> x.Key.Contains("Monitoring")))
    {
        if (!entry.IsDirectory)
        {
            entry.WriteToDirectory(@"D:\WinrarrFiles");
        }
    }
}

按照这个tutorial,这才是rar的正确阅读方式

using (Stream stream = File.OpenRead(@"C:\Code\sharpcompress.rar"))
{
    var reader = ReaderFactory.Open(stream);
    while (reader.MoveToNextEntry())
    {
        if (!reader.Entry.IsDirectory)
        {
            reader.WriteEntryToDirectory(@"C:\temp", new ExtractionOptions() { ExtractFullPath = true, Overwrite = true });
        }
    }
}