RarArchive Class
A RAR archive (RAR 1.5-4.x or RAR5) opened for random access from a seekable stream. It reads the archives created by an SFX module, solid archives (an entry is decoded after the entries it depends on), multi-volume archives (see ArchiveReaderOptions.VolumeResolver), and archives encrypted with AES, including their headers.
public sealed class RarArchive : ArchiveExample
using var stream = File.OpenRead(path);
using var archive = new RarArchive(stream);
Assert.Equal(RarFormatVersion.Rar5, archive.FormatVersion);
Assert.True(archive.IsSolid);
foreach (var entry in archive.Entries)
{
using var content = entry.Open();
using var buffer = new MemoryStream();
content.CopyTo(buffer);
Assert.Equal(entry.Length, buffer.Length);
}- Inheritance
ArchiveRarArchive
Constructors
| Name | Description |
|---|---|
| RarArchive(Stream, ArchiveReaderOptions?, bool) | Opens a RAR archive from a seekable stream. |
RarArchive(Stream, ArchiveReaderOptions?, bool)
RarArchive.csOpens a RAR archive from a seekable stream.
public RarArchive(Stream stream, ArchiveReaderOptions? options = null, bool leaveOpen = false)Parameters
streamStream- The first volume of the archive. It must be readable and seekable.
optionsArchiveReaderOptions?- The options, or
nullfor the defaults. leaveOpenbooltrueto leavestreamopen after the archive is disposed.
Exceptions
ArgumentExceptionstreamis not readable or not seekable.InvalidDataException- The stream is not a RAR archive, or the archive is corrupted.
ArchivePasswordException- The headers are encrypted and the password is missing or wrong.
NotSupportedException- The archive is a RAR 1.4 archive, or uses an encryption that is not supported.
Properties
| Name | Description |
|---|---|
| Comment | Gets the comment of the archive, or null when there is none, or when it cannot be decoded (a RAR 1.5 compression, a missing password, corrupted data). |
| Entries | Gets the entries of the archive, in the order of the archive. The service headers (comments, quick open data, ...) are not entries. |
| Format | Gets the format of the archive. |
| FormatVersion | Gets the version of the format of the archive. |
| IsMultiVolume | Gets a value indicating whether the archive is a volume of a multi-volume archive. |
| IsSolid | Gets a value indicating whether the archive is solid: the entries continue the compression dictionary of the previous ones. |
| VolumeCount | Gets the number of volumes that were read. |
Comment
RarArchive.csEntries
RarArchive.csGets the entries of the archive, in the order of the archive. The service headers (comments, quick open data, ...) are not entries.
public new IReadOnlyList<RarArchiveEntry> Entries { get; }Property value
Format
RarArchive.csFormatVersion
RarArchive.csGets the version of the format of the archive.
public RarFormatVersion FormatVersion { get; }Property value
IsMultiVolume
RarArchive.csIsSolid
RarArchive.csVolumeCount
RarArchive.csMethods
| Name | Description |
|---|---|
| GetEntry(string) | Gets the entry whose full name is entryName (an ordinal comparison), or null when there is none. |
GetEntry(string)
RarArchive.csGets the entry whose full name is entryName (an ordinal comparison), or null when there is none.
public new RarArchiveEntry? GetEntry(string entryName)Parameters
entryNamestring- The path of the entry in the archive, with
/separators.
Returns
RarArchiveEntry? The first entry whose ArchiveEntry.FullName is entryName, or null.