Class SevenZipArchiveEntry

Class SevenZipArchiveEntry

名称: Aspose.Zip.SevenZip 收藏: Aspose.Zip.dll (25.5.0)

代表一个单一的文件在7z档案中。

public abstract class SevenZipArchiveEntry : IArchiveFileEntry

Inheritance

object SevenZipArchiveEntry

Derived

SevenZipArchiveEntryEncrypted , SevenZipArchiveEntryPlain

Implements

IArchiveFileEntry

继承人

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Remarks

将 Aspose.Zip.SevenZip.SevenZipArchiveEntry 插入到 Aspose.Zip.SevenZip.SevenZipArchiveEntry 加密,以确定输入是否加密。

Properties

CompressedSize

收到压缩文件的尺寸。

public ulong CompressedSize { get; }

财产价值

ulong

CompressionSettings

接收压缩或压缩设置。

public SevenZipCompressionSettings CompressionSettings { get; }

财产价值

SevenZipCompressionSettings

FileAttributes

从主机系统获取文件属性。

protected FileAttributes FileAttributes { get; }

财产价值

FileAttributes

IsDirectory

收到一个值,表明输入是否代表一个目录。

public bool IsDirectory { get; }

财产价值

bool

ModificationTime

收到最后修改的日期和时间。

public DateTime ModificationTime { get; }

财产价值

DateTime

Name

收到存档中的输入名称。

public string Name { get; protected set; }

财产价值

string

Source

获取输入的数据源流。

protected Stream Source { get; }

财产价值

Stream

UncompressedSize

收到原始文件的尺寸。

public ulong UncompressedSize { get; }

财产价值

ulong

Methods

Extract(字符串, string)

通过提供的路径将输入到文件系统。

public FileInfo Extract(string path, string password = null)

Parameters

path string

路径到目的地文件. 如果文件已经存在,它将被过写。

password string

可选的密码来解密。

Returns

FileInfo

组成文件的文件信息。

Examples

using (var archive = new SevenZipArchive("archive.7z"))
{
    archive.Entries[0].Extract("data.bin");
}

Exceptions

ArgumentNullException

path’ is null.

SecurityException

召唤者没有所需的访问许可。

ArgumentException

path’ 是空的,只包含白色空间,或包含无效的字符。

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

指定的 path’, 文件名, 或两者都超过系统定义的最大长度. 例如,在基于 Windows 的平台上,路径必须小于 248 个字符, 文件名必须小于 260 个字符。

NotSupportedException

文件在 path’ 中间包含一个列(:)。

InvalidDataException

档案被腐败了。

Extract(流, string)

将输入到提供的流。

public void Extract(Stream destination, string password = null)

Parameters

destination Stream

目的地流,必须写作。

password string

可选的密码来解密。

Examples

用密码提取 zip 档案的输入。

using (var archive = new SevenZipArchive("archive.7z"))
{
    archive.Entries[0].Extract(httpResponseStream);
}

Exceptions

ArgumentException

destination’ does not support writing.

InvalidOperationException

档案不开放用于提取 - 或 - 此输入是一个目录。

InvalidDataException

输入中错误的数据

FinalizeCompressedData(流量、比特[])

写到输出流的任何标题,跟随压缩数据。

protected abstract int FinalizeCompressedData(Stream outputStream, byte[] encoderProperties)

Parameters

outputStream Stream

输出流入。

encoderProperties byte ( )

压缩机的特性。

Returns

int

输入后添加的“技术”比特的数量显著的数据块。

GetDestinationStream(Stream)

目的地流入口,可以装饰。

protected abstract Stream GetDestinationStream(Stream outputStream)

Parameters

outputStream Stream

输出流入。

Returns

Stream

目的地流入压缩。

Open(线条)

打开输入用于提取,并提供输入内容的流。

public Stream Open(string password = null)

Parameters

password string

可选的密码来解密。

Returns

Stream

代表入口内容的流。

Examples

使用:Stream decompressed = entry.Open();

.NET 4.0 或更高版本 - 使用 Stream.CopyTo 方法:decompressed.CopyTo(httpResponse.OutputStream)

.NET 3.5 和之前 - 手动复制比特:

byte[] buffer = new byte[8192];
int bytesRead;
while (0 < (bytesRead = decompressed.Read(buffer, 0, buffer.Length)))
 fileStream.Write(buffer, 0, bytesRead);
```</p>

#### Remarks

Read from the stream to get the original content of a file. See examples section.

#### Exceptions

 [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception)

The archive is not opened for extraction. - or - This entry is a directory.

 [InvalidDataException](https://learn.microsoft.com/dotnet/api/system.io.invaliddataexception)

Wrong data within the entry.

### <a id="Aspose_Zip_SevenZip_SevenZipArchiveEntry_CompressionProgressed"></a> CompressionProgressed

Raises when a portion of raw stream compressed.

```csharp
public event EventHandler<progresseventargs> CompressionProgressed

事件类型

EventHandler < ProgressEventArgs >

Examples

archive.Entries[0].CompressionProgressed += (s, e) =&gt; { int percent = (int)((100 * (long)e.ProceededBytes) / entrySourceStream.Length); };

Remarks

事件发送器是一个 Aspose.Zip.SevenZip.SevenZipArchiveEntry 例子。

不会在LZMA2输入的多层模式中引用。

 中文