Archive Class

An archive opened for random access: its entries are known when it is opened, and can be read in any order.

public abstract class Archive : IAsyncDisposable, IDisposable
Implements

Properties

NameDescription
EntriesGets the entries of the archive, in the order of the archive.
FormatGets the format of the archive.

Entries

Archive.cs

Gets the entries of the archive, in the order of the archive.

public IReadOnlyList<ArchiveEntry> Entries { get; }

Format

Gets the format of the archive.

public abstract ArchiveFormat Format { get; }

Property value

ArchiveFormat

Methods

NameDescription
Dispose()Releases the resources of the archive.
Dispose(bool)Releases the resources of the archive.
DisposeAsync()Releases the resources of the archive.
DisposeAsyncCore()Releases the resources of the archive asynchronously.
ExtractToDirectory(string, bool)Extracts the entries of the archive to a directory. An entry whose path leaves the directory (.., a rooted path, or a symbolic link that points outside of it) is rejected with an IOException.
ExtractToDirectoryAsync(string, bool, CancellationToken)Extracts the entries of the archive to a directory. An entry whose path leaves the directory (.., a rooted path, or a symbolic link that points outside of it) is rejected with an IOException.
GetEntry(string)Gets the entry whose full name is entryName (an ordinal comparison), or null when there is none.

Dispose overloads

Dispose()

Archive.cs

Releases the resources of the archive.

public void Dispose()

Dispose(bool)

Archive.cs

Releases the resources of the archive.

protected virtual void Dispose(bool disposing)
Parameters
disposing bool
true when called from Archive.Dispose.

DisposeAsync()

Archive.cs

Releases the resources of the archive.

net10.0

public ValueTask DisposeAsync()

net11.0

public ValueTask DisposeAsync()

Returns

ValueTask A task that completes when the archive is disposed.

DisposeAsyncCore()

Archive.cs

Releases the resources of the archive asynchronously.

protected virtual ValueTask DisposeAsyncCore()

Returns

ValueTask A task that completes when the resources are released.

ExtractToDirectory(string, bool)

Archive.cs

Extracts the entries of the archive to a directory. An entry whose path leaves the directory (.., a rooted path, or a symbolic link that points outside of it) is rejected with an IOException.

public void ExtractToDirectory(string destinationDirectoryName, bool overwriteFiles = false)

Parameters

destinationDirectoryName string
The directory to extract to. It is created when it does not exist.
overwriteFiles bool
true to replace the existing files; false to throw an IOException when a file exists.

ExtractToDirectoryAsync(string, bool, CancellationToken)

Archive.cs

Extracts the entries of the archive to a directory. An entry whose path leaves the directory (.., a rooted path, or a symbolic link that points outside of it) is rejected with an IOException.

net10.0

public Task ExtractToDirectoryAsync(string destinationDirectoryName, bool overwriteFiles = false, CancellationToken cancellationToken = default)

net11.0

public Task ExtractToDirectoryAsync(string destinationDirectoryName, bool overwriteFiles = false, CancellationToken cancellationToken = default)

Parameters

destinationDirectoryName string
The directory to extract to. It is created when it does not exist.
overwriteFiles bool
true to replace the existing files; false to throw an IOException when a file exists.
cancellationToken CancellationToken
The token to monitor for cancellation requests.

Returns

Task A task that completes when every entry is extracted.

GetEntry(string)

Archive.cs

Gets the entry whose full name is entryName (an ordinal comparison), or null when there is none.

public ArchiveEntry? GetEntry(string entryName)

Parameters

entryName string
The path of the entry in the archive, with / separators.

Returns

ArchiveEntry? The first entry whose ArchiveEntry.FullName is entryName, or null.