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
| Name | Description |
|---|---|
| Entries | Gets the entries of the archive, in the order of the archive. |
| Format | Gets the format of the archive. |
Entries
Archive.csGets the entries of the archive, in the order of the archive.
public IReadOnlyList<ArchiveEntry> Entries { get; }Property value
Format
Methods
| Name | Description |
|---|---|
| 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.csReleases the resources of the archive.
public void Dispose()Dispose(bool)
Archive.csReleases the resources of the archive.
Parameters
disposingbooltruewhen called fromArchive.Dispose.
DisposeAsync()
Archive.csDisposeAsyncCore()
Archive.csExtractToDirectory(string, bool)
Archive.csExtracts 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.
Parameters
destinationDirectoryNamestring- The directory to extract to. It is created when it does not exist.
overwriteFilesbooltrueto replace the existing files;falseto throw anIOExceptionwhen a file exists.
ExtractToDirectoryAsync(string, bool, CancellationToken)
Archive.csExtracts 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
destinationDirectoryNamestring- The directory to extract to. It is created when it does not exist.
overwriteFilesbooltrueto replace the existing files;falseto throw anIOExceptionwhen a file exists.cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
Task A task that completes when every entry is extracted.
GetEntry(string)
Archive.csGets the entry whose full name is entryName (an ordinal comparison), or null when there is none.
public ArchiveEntry? GetEntry(string entryName)Parameters
entryNamestring- The path of the entry in the archive, with
/separators.
Returns
ArchiveEntry? The first entry whose ArchiveEntry.FullName is entryName, or null.