SevenZipArchiveEntry Class

An entry of a SevenZipArchive. The times, the attributes and the Unix permissions of an entry can be changed in SevenZipArchiveMode.Create and SevenZipArchiveMode.Update modes with the Set methods (the properties of ArchiveEntry are read-only, and C# cannot add a setter to an overridden property).

public sealed class SevenZipArchiveEntry : ArchiveEntry
Inheritance
ArchiveEntry SevenZipArchiveEntry

Properties

NameDescription
ArchiveGets the archive of the entry.
AttributesGets the Windows attributes of the entry, without the bit with which 7-Zip marks the Unix permissions.
CompressedLengthGets the length of the packed content of the folder of the entry when the entry is the only file of its folder, 0 for an entry without content, or -1 when the folder has several files (a solid folder) or is not written yet.
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. The name of a directory ends with /.
IsDirectoryGets a value indicating whether the entry is a directory.
IsEncryptedGets a value indicating whether the content of the entry is encrypted with AES-256.
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. For a new entry, it is the number of bytes written to it.
LinkTargetGets the target of a symbolic link (an entry whose Unix mode is a link: its content is the target), or null.
UnixFileModeGets the Unix permissions of the entry, which 7-Zip stores in the high 16 bits of the attributes.

Gets the archive of the entry.

public SevenZipArchive Archive { get; }

Property value

SevenZipArchive

Gets the Windows attributes of the entry, without the bit with which 7-Zip marks the Unix permissions.

public override FileAttributes? Attributes { get; }

Property value

FileAttributes?

CompressedLength

SevenZipArchiveEntry.cs

Gets the length of the packed content of the folder of the entry when the entry is the only file of its folder, 0 for an entry without content, or -1 when the folder has several files (a solid folder) or is not written yet.

public override 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 override uint? Crc32 { get; }

Property value

uint?

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

public override DateTimeOffset? CreationTime { get; }

Property value

DateTimeOffset?

Gets the path of the entry in the archive, with / separators. The name of a directory ends with /.

public override string FullName { get; }

Property value

string

Gets a value indicating whether the entry is a directory.

public override bool IsDirectory { get; }

Property value

bool

Gets a value indicating whether the content of the entry is encrypted with AES-256.

public override bool IsEncrypted { get; }

Property value

bool

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

public override DateTimeOffset? LastAccessTime { get; }

Property value

DateTimeOffset?

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

public override DateTimeOffset? LastWriteTime { get; }

Property value

DateTimeOffset?

Gets the length of the content of the entry. For a new entry, it is the number of bytes written to it.

public override long Length { get; }

Property value

long

Gets the target of a symbolic link (an entry whose Unix mode is a link: its content is the target), or null.

public override string? LinkTarget { get; }

Property value

string?

Gets the Unix permissions of the entry, which 7-Zip stores in the high 16 bits of the attributes.

public override UnixFileMode? UnixFileMode { get; }

Property value

UnixFileMode?

Methods

NameDescription
Delete()Deletes the entry from the archive.
Open()Opens the content of the entry: a read-only stream for an entry of the archive, or a write-only stream for a new entry (once). The read stream checks the CRC-32 of the content at its end.
SetAttributes(FileAttributes?)Sets the Windows attributes of the entry (their low 16 bits). The Unix permissions are kept.
SetCreationTime(DateTimeOffset?)Sets the time the entry was created.
SetLastAccessTime(DateTimeOffset?)Sets the last time the entry was accessed.
SetLastWriteTime(DateTimeOffset?)Sets the last time the entry was modified.
SetUnixFileMode(UnixFileMode?)Sets the Unix permissions of the entry, which 7-Zip stores in the high 16 bits of the attributes with the type of the entry (a file, a directory or a symbolic link).

Deletes the entry from the archive.

public void Delete()

Exceptions

NotSupportedException
The archive is not in SevenZipArchiveMode.Update mode.

Opens the content of the entry: a read-only stream for an entry of the archive, or a write-only stream for a new entry (once). The read stream checks the CRC-32 of the content at its end.

public override Stream Open()

Returns

Stream The content of the entry.

Exceptions

InvalidOperationException
The entry is a directory, or another new entry is being written.
IOException
The new entry is already opened.
InvalidDataException
The archive is corrupted.
ArchivePasswordException
The entry is encrypted and the password is missing or wrong.
NotSupportedException
The entry is compressed with a method that is not supported.

SetAttributes(FileAttributes?)

SevenZipArchiveEntry.cs

Sets the Windows attributes of the entry (their low 16 bits). The Unix permissions are kept.

public void SetAttributes(FileAttributes? value)

Parameters

value FileAttributes?
The attributes, or null to not store them.

SetCreationTime(DateTimeOffset?)

SevenZipArchiveEntry.cs

Sets the time the entry was created.

public void SetCreationTime(DateTimeOffset? value)

Parameters

value DateTimeOffset?
The time, or null to not store it.

SetLastAccessTime(DateTimeOffset?)

SevenZipArchiveEntry.cs

Sets the last time the entry was accessed.

public void SetLastAccessTime(DateTimeOffset? value)

Parameters

value DateTimeOffset?
The time, or null to not store it.

SetLastWriteTime(DateTimeOffset?)

SevenZipArchiveEntry.cs

Sets the last time the entry was modified.

public void SetLastWriteTime(DateTimeOffset? value)

Parameters

value DateTimeOffset?
The time, or null to not store it.

SetUnixFileMode(UnixFileMode?)

SevenZipArchiveEntry.cs

Sets the Unix permissions of the entry, which 7-Zip stores in the high 16 bits of the attributes with the type of the entry (a file, a directory or a symbolic link).

public void SetUnixFileMode(UnixFileMode? value)

Parameters

value UnixFileMode?
The permissions, or null to not store them.