ExtractAllEntries doesn't follow the same logic as Entries for detecting multi part rar files #680

Closed
opened 2026-01-29 22:15:48 +00:00 by claunia · 0 comments
Owner

Originally created by @Kimi-Arthur on GitHub (May 7, 2025).

Hello there,

I'm trying to use ExtractAllEntries due to Entries having performance issue by the suggestion found here.

However, ExtractAllEntries won't work with multi part rar files.

Here is a simple example to demo the issue:

using System;
using System.Linq;
using SharpCompress.Archives;

namespace SharpCompressIssue;

class Program {
    static void Main(string[] args) {
        var archive = ArchiveFactory.Open("a.part01.rar");
        Console.WriteLine("Entries:");
        foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)
                     .Select(entry => entry.Key)) {
            Console.WriteLine($"\t{entry}");
        }

        Console.WriteLine("ExtractAllEntries:");
        using var reader = archive.ExtractAllEntries();

        while (reader.MoveToNextEntry()) {
            var entry = reader.Entry;
            if (!entry.IsDirectory) {
                Console.WriteLine($"\t{entry.Key}");
            }
        }
    }
}

It will give the result like this:

Entries:
        Complete.png
        Magic.png
        Summon.png
        Support.png
ExtractAllEntries:
Unhandled exception. SharpCompress.Common.MultiVolumeExtractionException: Streamed archive is a Multi-volume archive.  Use different RarReader method to extract.
   at SharpCompress.Readers.Rar.SingleVolumeRarReader.ValidateArchive(RarVolume archive)
   at SharpCompress.Readers.Rar.RarReader.GetEntries(Stream stream)+MoveNext()
   at SharpCompress.Readers.AbstractReader`2.LoadStreamForReading(Stream stream)
   at SharpCompress.Readers.AbstractReader`2.MoveToNextEntry()
   at SharpCompressIssue.Program.Main(String[] args) in /Users/jingbian/Projects/KifaNet/Experimental/SharpCompressIssue/Program.cs:line 19

You can find the full package here or you can also create the multi part rar files.

Originally created by @Kimi-Arthur on GitHub (May 7, 2025). Hello there, I'm trying to use `ExtractAllEntries` due to `Entries` having performance issue by the suggestion found [here](https://stackoverflow.com/a/44379540). However, `ExtractAllEntries` won't work with multi part rar files. Here is a simple example to demo the issue: ```csharp using System; using System.Linq; using SharpCompress.Archives; namespace SharpCompressIssue; class Program { static void Main(string[] args) { var archive = ArchiveFactory.Open("a.part01.rar"); Console.WriteLine("Entries:"); foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory) .Select(entry => entry.Key)) { Console.WriteLine($"\t{entry}"); } Console.WriteLine("ExtractAllEntries:"); using var reader = archive.ExtractAllEntries(); while (reader.MoveToNextEntry()) { var entry = reader.Entry; if (!entry.IsDirectory) { Console.WriteLine($"\t{entry.Key}"); } } } } ``` It will give the result like this: ``` Entries: Complete.png Magic.png Summon.png Support.png ExtractAllEntries: Unhandled exception. SharpCompress.Common.MultiVolumeExtractionException: Streamed archive is a Multi-volume archive. Use different RarReader method to extract. at SharpCompress.Readers.Rar.SingleVolumeRarReader.ValidateArchive(RarVolume archive) at SharpCompress.Readers.Rar.RarReader.GetEntries(Stream stream)+MoveNext() at SharpCompress.Readers.AbstractReader`2.LoadStreamForReading(Stream stream) at SharpCompress.Readers.AbstractReader`2.MoveToNextEntry() at SharpCompressIssue.Program.Main(String[] args) in /Users/jingbian/Projects/KifaNet/Experimental/SharpCompressIssue/Program.cs:line 19 ``` You can find the full package [here](https://drive.google.com/file/d/1gXYUoouy7tX-tEKEI-nrce-yc5DE1vEr/view?usp=sharing) or you can also create the multi part rar files.
claunia added the enhancementup for grabs labels 2026-01-29 22:15:48 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#680