Reading a rar stream from a rar file gets NotSupportedException Specified method is not supported #648

Open
opened 2026-01-29 22:15:15 +00:00 by claunia · 1 comment
Owner

Originally created by @Sonic3R on GitHub (Aug 6, 2024).

Hi,

I'm using latest library version 0.37.2, at this moment of creating issue.

I have multi volume archive protected by password. That archive contains a subset of other archives, rar files especially.

There is my code:

var folder = @"D:\myfolder";
var rars = Directory.GetFiles(folder, "*.rar");
var pass = "abcdef1230213";

using var archive = RarArchive.Open(rars.Select(File.OpenRead), new SharpCompress.Readers.ReaderOptions { Password = pass });
foreach (var entry in archive.Entries.Where(c => !c.IsDirectory))
{
  Console.WriteLine(entry.Key);

  if (entry.Key!.EndsWith(".rar"))
  {
        using var stream = entry.OpenEntryStream();
        var r = RarArchive.IsRarFile(stream);
        using var subArchive = RarArchive.Open(stream);
        if (subArchive.Entries.Count > 0)   // here is the exception occurrence
        {
            foreach (var subEntry in subArchive.Entries.Where(c => !c.IsDirectory))
            {
                Console.WriteLine(subEntry.Key);
            }
        }
    }
}

What I'm doing wrong ?

Originally created by @Sonic3R on GitHub (Aug 6, 2024). Hi, I'm using latest library version 0.37.2, at this moment of creating issue. I have multi volume archive protected by password. That archive contains a subset of other archives, rar files especially. There is my code: ``` var folder = @"D:\myfolder"; var rars = Directory.GetFiles(folder, "*.rar"); var pass = "abcdef1230213"; using var archive = RarArchive.Open(rars.Select(File.OpenRead), new SharpCompress.Readers.ReaderOptions { Password = pass }); foreach (var entry in archive.Entries.Where(c => !c.IsDirectory)) { Console.WriteLine(entry.Key); if (entry.Key!.EndsWith(".rar")) { using var stream = entry.OpenEntryStream(); var r = RarArchive.IsRarFile(stream); using var subArchive = RarArchive.Open(stream); if (subArchive.Entries.Count > 0) // here is the exception occurrence { foreach (var subEntry in subArchive.Entries.Where(c => !c.IsDirectory)) { Console.WriteLine(subEntry.Key); } } } } ``` What I'm doing wrong ?
Author
Owner

@adamhathcock commented on GitHub (Aug 6, 2024):

Maybe the inner rar needs a password? I can't tell from the usage, A full stacktrace would help with the password issue

@adamhathcock commented on GitHub (Aug 6, 2024): Maybe the inner rar needs a password? I can't tell from the usage, A full stacktrace would help with the password issue
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#648