# ArchiveReader

Reads selected archive content without filesystem publication or executing its contents.

Class 

`OfficeIMO.Archives`

**Namespace**

`OfficeIMO.Archives`

**Assembly**

`OfficeIMO.Archives`

**Source revision**

`273d35d5ba8a` with working tree changes

**Source**

[ArchiveReader.cs:10](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.cs#L10)

**Modifiers**

static

Reads selected archive content without filesystem publication or executing its contents.

## Inheritance

- object
- ArchiveReader

Filter members 

Show inherited

## Methods

EnumerateZip 2 overloads

`public static IReadOnlyList<ArchiveEntryDescriptor> EnumerateZip(string zipPath, ArchiveTraversalOptions? options = null)` [#](#method-enumeratezip-string-officeimo-archives-archivetraversaloptions)

[ArchiveReader.Traversal.cs:14](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Traversal.cs#L14)

Enumerates ZIP entries from a path.

Parameters

**zipPath string required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? = null optional**

Returns

`IReadOnlyList<ArchiveEntryDescriptor>`

`public static IReadOnlyList<ArchiveEntryDescriptor> EnumerateZip(Stream zipStream, ArchiveTraversalOptions? options = null)` [#](#method-enumeratezip-io-stream-officeimo-archives-archivetraversaloptions)

[ArchiveReader.Traversal.cs:26](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Traversal.cs#L26)

Enumerates ZIP entries from a stream.

Parameters

**zipStream System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? = null optional**

Returns

`IReadOnlyList<ArchiveEntryDescriptor>`

`public static Rar5ArchiveInfo InspectRar5(Stream source, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-inspectrar5-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Rar5.cs:25](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Rar5.cs#L25)

Reads the authoritative file table and verifies the archive comment when stored. The source remains open.

Parameters

**source System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Rar5ArchiveInfo`

`public static Rar5ArchiveInfo InspectRar5Volumes(IReadOnlyList<Stream> volumes, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-inspectrar5volumes-collections-generic-ireadonlylist-system-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Rar5.cs:36](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Rar5.cs#L36)

Reads the file table and optional comment of a complete RAR5 set supplied in volume order. Each stream is read from its current position to EOF and left open.

Parameters

**volumes System.Collections.Generic.IReadOnlyList<System.IO.Stream> required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`Rar5ArchiveInfo`

`public static IReadOnlyList<Rar5ArchiveEntry> ListRar5(Stream source, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-listrar5-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Rar5.cs:20](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Rar5.cs#L20)

Lists the authoritative file headers of a RAR5 archive in file order. The source remains open.

Parameters

**source System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<Rar5ArchiveEntry>`

`public static IReadOnlyList<SevenZipArchiveEntry> ListSevenZip(Stream source, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-listsevenzip-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.SevenZip.cs:11](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.SevenZip.cs#L11)

Lists the validated file table of a 7z archive. Encoded metadata may be decompressed, but file payloads are not decoded. The source is read from its current position and left open.

Parameters

**source System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<SevenZipArchiveEntry>`

Exceptions

- `NotSupportedException` – The archive uses encryption or an unsupported structure.

`public static IReadOnlyList<TarArchiveEntry> ListTar(Stream source, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-listtar-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Tar.cs:50](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Tar.cs#L50)

Lists every member of a plain or compressed TAR, including directories, symbolic and hard links with their authored targets, and device records, without reading file content or validating names as output paths. Reads from the stream's current position to EOF and leaves the stream open.

Parameters

**source System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<TarArchiveEntry>`

Exceptions

- `OfficeInspectionResourceLimitException` – A configured or managed admission ceiling is exhausted.
- `InvalidDataException` – The archive is corrupt or truncated.
- `ArchiveCorruptionException` – The Zstandard, xz or lzip wrapper is corrupt or truncated.
- `NotSupportedException` – The input is not TAR, or uses sparse or multi-volume members.

ReadRar5 2 overloads

`public static IReadOnlyList<ArchiveEntryData> ReadRar5(byte[] data, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readrar5-byte-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Rar5.cs:42](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Rar5.cs#L42)

Returns selected stored RAR5 files in primary header order after verifying their checksums. The caller must keep source bytes unchanged for the duration of the read.

Parameters

**data byte[] required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

`public static IReadOnlyList<ArchiveEntryData> ReadRar5(Stream source, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readrar5-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Rar5.cs:54](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Rar5.cs#L54)

Reads and verifies selected stored RAR5 entries from the stream's current position to EOF, leaving it open.

Parameters

**source System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

`public static IReadOnlyList<ArchiveEntryData> ReadRar5Volumes(IReadOnlyList<Stream> volumes, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readrar5volumes-collections-generic-ireadonlylist-system-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Rar5.cs:65](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Rar5.cs#L65)

Returns the verified stored files of a complete RAR5 set supplied in volume order. Each stream is read from its current position to EOF and left open.

Parameters

**volumes System.Collections.Generic.IReadOnlyList<System.IO.Stream> required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

ReadSevenZip 2 overloads

`public static IReadOnlyList<ArchiveEntryData> ReadSevenZip(byte[] data, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readsevenzip-byte-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.SevenZip.cs:21](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.SevenZip.cs#L21)

Reads selected regular files from 7z bytes, verifying the complete containing solid folders before returning. The caller must leave the input bytes unchanged for the duration of the call.

Parameters

**data byte[] required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

`public static IReadOnlyList<ArchiveEntryData> ReadSevenZip(Stream source, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readsevenzip-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.SevenZip.cs:34](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.SevenZip.cs#L34)

Reads selected regular files of a 7z archive from the stream's current position, leaving it open. Entire selected solid folders are verified, even when only one member is requested.

Parameters

**source System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

ReadTar 2 overloads

`public static IReadOnlyList<ArchiveEntryData> ReadTar(byte[] bytes, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readtar-byte-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Tar.cs:15](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Tar.cs#L15)

Reads the selected regular files of a TAR, plain or compressed with gzip, Zstandard, xz or lzip (.tar.gz, .tar.zst, .tar.xz, .tar.lz), from bytes, with the same path safety, collision and limit checks as extraction. Links, devices and directories are not returned; use [ArchiveReader.ListTar](/api/archives/officeimo-archives-archivereader/) for their metadata.

Parameters

**bytes byte[] required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

Exceptions

- `OfficeInspectionResourceLimitException` – A configured or managed admission ceiling is exhausted.
- `InvalidDataException` – The archive is corrupt, truncated or unsafe.
- `ArchiveCorruptionException` – The Zstandard, xz or lzip wrapper is corrupt or truncated.
- `NotSupportedException` – The input is not TAR, or uses sparse or multi-volume members.

`public static IReadOnlyList<ArchiveEntryData> ReadTar(Stream source, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readtar-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.Tar.cs:31](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Tar.cs#L31)

Reads the selected regular files of a plain or compressed TAR from the stream's current position to EOF. Supports nonseekable streams, leaves the caller's stream open and advances it by the bytes read.

Parameters

**source System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

Exceptions

- `OfficeInspectionResourceLimitException` – A configured or managed admission ceiling is exhausted.
- `InvalidDataException` – The archive is corrupt, truncated or unsafe.
- `ArchiveCorruptionException` – The Zstandard, xz or lzip wrapper is corrupt or truncated.
- `NotSupportedException` – The input is not TAR, or uses sparse or multi-volume members.

ReadZip 2 overloads

`public static IReadOnlyList<ArchiveEntryData> ReadZip(byte[] bytes, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readzip-byte-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.cs:10](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.cs#L10)

Reads a ZIP from bytes using the same strict member validation as extraction. Returns only after every selected payload is fully verified. Do not modify the input during this call.

Parameters

**bytes byte[] required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

Exceptions

- `OfficeInspectionResourceLimitException` – A configured or managed admission ceiling is exhausted.

`public static IReadOnlyList<ArchiveEntryData> ReadZip(Stream source, ArchiveReadOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-readzip-io-stream-officeimo-archives-archivereadoptions-threading-cancellationtoken)

[ArchiveReader.cs:23](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.cs#L23)

Reads from the stream's current position to EOF into a bounded snapshot. Supports nonseekable streams, leaves the caller's stream open, and advances its position by the bytes read. Selected content is independent of the stream after return.

Parameters

**source System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveReadOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`IReadOnlyList<ArchiveEntryData>`

Exceptions

- `OfficeInspectionResourceLimitException` – A configured or managed admission ceiling is exhausted.

TraverseZip 6 overloads

`public static ArchiveTraversalResult TraverseZip(string zipPath, ArchiveTraversalOptions? options = null)` [#](#method-traversezip-string-officeimo-archives-archivetraversaloptions)

[ArchiveReader.Traversal.cs:33](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Traversal.cs#L33)

Traverses ZIP entries from a path and returns accepted entries with warnings.

Parameters

**zipPath string required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? = null optional**

Returns

`ArchiveTraversalResult`

`public static ArchiveTraversalResult TraverseZip(Stream zipStream, ArchiveTraversalOptions? options = null)` [#](#method-traversezip-io-stream-officeimo-archives-archivetraversaloptions)

[ArchiveReader.Traversal.cs:45](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Traversal.cs#L45)

Traverses ZIP entries from a stream and returns accepted entries with warnings.

Parameters

**zipStream System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? = null optional**

Returns

`ArchiveTraversalResult`

`public static ArchiveTraversalResult TraverseZip(Stream zipStream, ArchiveTraversalOptions? options, CancellationToken cancellationToken)` [#](#method-traversezip-io-stream-officeimo-archives-archivetraversaloptions-threading-cancellationtoken)

[ArchiveReader.Traversal.cs:51](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Traversal.cs#L51)

Traverses a ZIP source with a physical-entry preflight and cooperative cancellation.

Parameters

**zipStream System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? required**

**cancellationToken System.Threading.CancellationToken required**

Returns

`ArchiveTraversalResult`

`public static ArchiveTraversalResult TraverseZip(ZipArchive archive, ArchiveTraversalOptions? options = null)` [#](#method-traversezip-io-compression-ziparchive-officeimo-archives-archivetraversaloptions)

[ArchiveReader.Traversal.cs:70](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Traversal.cs#L70)

Traverses ZIP entries from an already opened archive and returns accepted entries with warnings. Names are already decoded by its owner; raw filename encoding cannot be validated or changed by this overload.

Parameters

**archive System.IO.Compression.ZipArchive required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? = null optional**

Returns

`ArchiveTraversalResult`

`public static ArchiveTraversalResult TraverseZip(ZipArchive archive, ArchiveTraversalOptions? options, CancellationToken cancellationToken)` [#](#method-traversezip-io-compression-ziparchive-officeimo-archives-archivetraversaloptions-threading-cancellationtoken)

[ArchiveReader.Traversal.cs:77](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Traversal.cs#L77)

Traverses an opened archive with bounded metadata processing and cooperative cancellation. Names retain the decoding policy applied when the archive was opened.

Parameters

**archive System.IO.Compression.ZipArchive required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? required**

**cancellationToken System.Threading.CancellationToken required**

Returns

`ArchiveTraversalResult`

`public static ArchiveTraversalResult TraverseZip(ArchiveInspection inspection, ArchiveTraversalOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-traversezip-officeimo-archives-archiveinspection-officeimo-archives-archivetraversaloptions-threading-cancellationtoken)

[ArchiveReader.Traversal.cs:101](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.Traversal.cs#L101)

Applies ZIP ingestion selection policy to an existing immutable inspection without reparsing its input. Metadata acceptance does not verify member content; use inspection.OpenRead or ReadMembers for payloads.

Parameters

**inspection OfficeIMO.Archives.ArchiveInspection required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

Returns

`ArchiveTraversalResult`

`public static void ValidateZipSource(Stream zipStream, ArchiveTraversalOptions? options = null, CancellationToken cancellationToken = default)` [#](#method-validatezipsource-io-stream-officeimo-archives-archivetraversaloptions-threading-cancellationtoken)

[ArchiveReader.TraversalSource.cs:14](https://github.com/EvotecIT/OfficeIMO/blob/273d35d5ba8ab8ce3f6f1238631241c0cea26d14/OfficeIMO.Archives/ArchiveReader.TraversalSource.cs#L14)

Validates compressed size and physical entry count on a seekable ZIP source before opening a ZipArchive. The source position is restored. This check is safe only if the caller keeps the source bytes immutable until its archive has been read. Prefer a stream or path TraverseZip overload for mutable or untrusted sources.

Parameters

**zipStream System.IO.Stream required**

**options OfficeIMO.Archives.ArchiveTraversalOptions? = null optional**

**cancellationToken System.Threading.CancellationToken = default optional**

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

<!-- PowerForge markdown artifact sha256:AE903315F9C802D315F8471DE416F3544F0B4EB62B56EA2B99E2156D0FE83BEA -->
