Multi-volume Rar streams #167

Open
opened 2026-01-29 22:07:43 +00:00 by claunia · 0 comments
Owner

Originally created by @krvi on GitHub (Apr 20, 2017).

I'm attempting to read the contents of multi-volume Rar archive. The archive is never written to disk so I need to read them as streams. I do the following steps.
1: Declare a dictionary, rather than List, simply for ease of ordering/sorting.
var rd = new Dictionary<string, Stream>();
2: Populate the dictionary.
2.5: Ensure that the streams are ordered. For example:
file.part1.rar
file.part2.rar
file.part2.rar

or
file.rar
file.r00
file.r01

3: Open archive
var ra = RarArchive.Open(rd.Values.AsEnumerable());

From what I've read it is supposed to work with this procedure. However, it does not work.
ra.WriteToDirectory(@"C:\test\"); Produces nothing and neither does

foreach (var e in ra.Entries)
    {
          e.WriteToDirectory(@"C:\test\");
          //or
          var fs = new FileStream(@"C:\test\" + e.Key, FileMode.Create, FileAccess.Write);
          e.WriteTo(fs);
          fs.Close();
    }

If I open the archive with only the first volume with ArchiveFactory
var ra = ArchiveFactory.Open(rd.Values.First());
It works, for the whole files in the first volume. I can successfully use them and write them to disk.

What am I missing to be able to read the whole archive? Is this intended behavior or a bug?

Originally created by @krvi on GitHub (Apr 20, 2017). I'm attempting to read the contents of multi-volume Rar archive. The archive is never written to disk so I need to read them as streams. I do the following steps. 1: Declare a dictionary, rather than List, simply for ease of ordering/sorting. `var rd = new Dictionary<string, Stream>();` 2: Populate the dictionary. 2.5: Ensure that the streams are ordered. For example: _file.part1.rar file.part2.rar file.part2.rar_ or _file.rar file.r00 file.r01_ 3: Open archive `var ra = RarArchive.Open(rd.Values.AsEnumerable());` From what I've [read](http://sharpcompress2.rssing.com/chan-6339576/all_p3.html) it is supposed to work with this procedure. However, it does not work. `ra.WriteToDirectory(@"C:\test\");` Produces nothing and neither does ``` foreach (var e in ra.Entries) { e.WriteToDirectory(@"C:\test\"); //or var fs = new FileStream(@"C:\test\" + e.Key, FileMode.Create, FileAccess.Write); e.WriteTo(fs); fs.Close(); } ``` If I open the archive with only the first volume with ArchiveFactory `var ra = ArchiveFactory.Open(rd.Values.First());` It works, for the _whole_ files _in the first volume_. I can successfully use them and write them to disk. What am I missing to be able to read the whole archive? Is this intended behavior or a bug?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#167