ArchiveEntry Class
An entry of an archive: a file, a directory, or a symbolic link.
public abstract class ArchiveEntryProperties
| Name | Description |
|---|---|
| Attributes | Gets the Windows attributes of the entry, or null when the archive does not store them. |
| CompressedLength | Gets the length of the compressed content of the entry, or -1 when it is not known (the content of the entries of a solid block is compressed together). |
| Crc32 | Gets the CRC-32 of the content of the entry, or null when the archive does not store it. |
| CreationTime | Gets the time the entry was created, or null when the archive does not store it. |
| FullName | Gets the path of the entry in the archive, with / separators. |
| HardLinkTarget | Gets the path, in the archive, of the entry whose content this entry shares (a hard link of tar or RAR, a file copy of RAR), or null. Extracting the entry copies the file extracted for the target. |
| IsDirectory | Gets a value indicating whether the entry is a directory. |
| IsEncrypted | Gets a value indicating whether the content of the entry is encrypted. |
| LastAccessTime | Gets the last time the entry was accessed, or null when the archive does not store it. |
| LastWriteTime | Gets the last time the entry was modified, or null when the archive does not store it. |
| Length | Gets the length of the content of the entry, or -1 when the archive does not tell it before the content is read. |
| LinkTarget | Gets the target of a symbolic link, or null when the entry is not a symbolic link. |
| Name | Gets the file name of the entry: the last segment of ArchiveEntry.FullName. |
| UnixFileMode | Gets the Unix permissions of the entry, or null when the archive does not store them. |
Attributes
ArchiveEntry.csGets the Windows attributes of the entry, or null when the archive does not store them.
public virtual FileAttributes? Attributes { get; }Property value
CompressedLength
Crc32
ArchiveEntry.csCreationTime
ArchiveEntry.csGets the time the entry was created, or null when the archive does not store it.
public virtual DateTimeOffset? CreationTime { get; }Property value
FullName
HardLinkTarget
ArchiveEntry.csIsDirectory
IsEncrypted
ArchiveEntry.csLastAccessTime
ArchiveEntry.csGets the last time the entry was accessed, or null when the archive does not store it.
public virtual DateTimeOffset? LastAccessTime { get; }Property value
LastWriteTime
Gets the last time the entry was modified, or null when the archive does not store it.
public abstract DateTimeOffset? LastWriteTime { get; }Property value
Length
LinkTarget
ArchiveEntry.csName
ArchiveEntry.csGets the file name of the entry: the last segment of ArchiveEntry.FullName.
public string Name { get; }Property value
UnixFileMode
ArchiveEntry.csGets the Unix permissions of the entry, or null when the archive does not store them.
public virtual UnixFileMode? UnixFileMode { get; }Property value
Methods
| Name | Description |
|---|---|
| ExtractToFile(string, bool) | Extracts the content of the entry to a file, and sets its last write time. |
| ExtractToFileAsync(string, bool, CancellationToken) | Extracts the content of the entry to a file, and sets its last write time. |
| Open() | Opens the content of the entry. The stream checks the CRC or the hash the archive stores, and throws an InvalidDataException at its end when they do not match. |
| OpenAsync(CancellationToken) | Opens the content of the entry. |
| ToString() | Returns a string that represents the current object. |
ExtractToFile(string, bool)
ArchiveEntry.csExtracts the content of the entry to a file, and sets its last write time.
Parameters
destinationFileNamestring- The path of the file to create.
overwritebooltrueto replace an existing file;falseto throw anIOExceptionwhen the file exists.
ExtractToFileAsync(string, bool, CancellationToken)
ArchiveEntry.csExtracts the content of the entry to a file, and sets its last write time.
public Task ExtractToFileAsync(string destinationFileName, bool overwrite = false, CancellationToken cancellationToken = default)Parameters
destinationFileNamestring- The path of the file to create.
overwritebooltrueto replace an existing file;falseto throw anIOExceptionwhen the file exists.cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
Task A task that completes when the file is written.
Open()
Opens the content of the entry. The stream checks the CRC or the hash the archive stores, and throws an InvalidDataException at its end when they do not match.
public abstract Stream Open()Returns
Stream A read-only stream of the content of the entry.
Exceptions
InvalidDataException- The archive is corrupted.
ArchivePasswordException- The entry is encrypted and the password is missing or wrong.
NotSupportedException- The entry is compressed or encrypted with a method that is not supported.
OpenAsync(CancellationToken)
ArchiveEntry.csOpens the content of the entry.
public virtual Task<Stream> OpenAsync(CancellationToken cancellationToken = default)Parameters
cancellationTokenCancellationToken- The token to monitor for cancellation requests.
Returns
Task<Stream> A read-only stream of the content of the entry.
Exceptions
InvalidDataException- The archive is corrupted.
ArchivePasswordException- The entry is encrypted and the password is missing or wrong.
NotSupportedException- The entry is compressed or encrypted with a method that is not supported.