ArchiveEntry Class

An entry of an archive: a file, a directory, or a symbolic link.

public abstract class ArchiveEntry

Properties

NameDescription
AttributesGets the Windows attributes of the entry, or null when the archive does not store them.
CompressedLengthGets 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).
Crc32Gets the CRC-32 of the content of the entry, or null when the archive does not store it.
CreationTimeGets the time the entry was created, or null when the archive does not store it.
FullNameGets the path of the entry in the archive, with / separators.
HardLinkTargetGets 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.
IsDirectoryGets a value indicating whether the entry is a directory.
IsEncryptedGets a value indicating whether the content of the entry is encrypted.
LastAccessTimeGets the last time the entry was accessed, or null when the archive does not store it.
LastWriteTimeGets the last time the entry was modified, or null when the archive does not store it.
LengthGets the length of the content of the entry, or -1 when the archive does not tell it before the content is read.
LinkTargetGets the target of a symbolic link, or null when the entry is not a symbolic link.
NameGets the file name of the entry: the last segment of ArchiveEntry.FullName.
UnixFileModeGets the Unix permissions of the entry, or null when the archive does not store them.

Attributes

ArchiveEntry.cs

Gets the Windows attributes of the entry, or null when the archive does not store them.

public virtual FileAttributes? Attributes { get; }

Property value

FileAttributes?

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).

public abstract long CompressedLength { get; }

Property value

long

Gets the CRC-32 of the content of the entry, or null when the archive does not store it.

public virtual uint? Crc32 { get; }

Property value

uint?

CreationTime

ArchiveEntry.cs

Gets the time the entry was created, or null when the archive does not store it.

public virtual DateTimeOffset? CreationTime { get; }

Property value

DateTimeOffset?

FullName

Gets the path of the entry in the archive, with / separators.

public abstract string FullName { get; }

Property value

string

HardLinkTarget

ArchiveEntry.cs

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.

public virtual string? HardLinkTarget { get; }

Property value

string?

IsDirectory

Gets a value indicating whether the entry is a directory.

public abstract bool IsDirectory { get; }

Property value

bool

IsEncrypted

ArchiveEntry.cs

Gets a value indicating whether the content of the entry is encrypted.

public virtual bool IsEncrypted { get; }

Property value

bool

LastAccessTime

ArchiveEntry.cs

Gets the last time the entry was accessed, or null when the archive does not store it.

public virtual DateTimeOffset? LastAccessTime { get; }

Property value

DateTimeOffset?

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

DateTimeOffset?

Length

Gets the length of the content of the entry, or -1 when the archive does not tell it before the content is read.

public abstract long Length { get; }

Property value

long

LinkTarget

ArchiveEntry.cs

Gets the target of a symbolic link, or null when the entry is not a symbolic link.

public virtual string? LinkTarget { get; }

Property value

string?

Gets the file name of the entry: the last segment of ArchiveEntry.FullName.

public string Name { get; }

Property value

string

UnixFileMode

ArchiveEntry.cs

Gets the Unix permissions of the entry, or null when the archive does not store them.

public virtual UnixFileMode? UnixFileMode { get; }

Property value

UnixFileMode?

Methods

NameDescription
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.cs

Extracts the content of the entry to a file, and sets its last write time.

public void ExtractToFile(string destinationFileName, bool overwrite = false)

Parameters

destinationFileName string
The path of the file to create.
overwrite bool
true to replace an existing file; false to throw an IOException when the file exists.

ExtractToFileAsync(string, bool, CancellationToken)

ArchiveEntry.cs

Extracts 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

destinationFileName string
The path of the file to create.
overwrite bool
true to replace an existing file; false to throw an IOException when the file exists.
cancellationToken CancellationToken
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.cs

Opens the content of the entry.

public virtual Task<Stream> OpenAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken
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.

ToString()

ArchiveEntry.cs

Returns a string that represents the current object.

public override string ToString()

Returns

string A string that represents the current object.