Class CabEntry

Class CabEntry

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

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

public sealed class CabEntry : IArchiveFileEntry

Inheritance

object CabEntry

Implements

IArchiveFileEntry

继承人

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

Properties

Length

接收入口的长度为比特。

public uint Length { get; }

财产价值

uint

ModificationTime

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

public DateTime ModificationTime { get; }

财产价值

DateTime

Name

收到存档中的输入名称。

public string Name { get; }

财产价值

string

Methods

Extract(线条)

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

public FileInfo Extract(string path)

Parameters

path string

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

Returns

FileInfo

组成文件的文件信息。

Examples

using (var archive = new CabArchive("archive.cab"))
{
    archive.Entries[0].Extract("data.bin");
}

Exceptions

ArgumentNullException

path’ is null.

SecurityException

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

ArgumentException

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

UnauthorizedAccessException

拒绝访问 path" 文件。

PathTooLongException

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

NotSupportedException

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

FileNotFoundException

文件未找到。

DirectoryNotFoundException

指定的路径是无效的,例如在无地图驱动器上。

IOException

文件已经开放了。

NotSupportedException

流动启动因错误数据而失败。

InvalidDataException

档案被腐败了。

Extract(Stream)

将输入到提供的流。

public void Extract(Stream destination)

Parameters

destination Stream

目的地流,必须写作。

Examples

提取一个输入的CAB档案。

Using (var archive = new CabArchive("archive.cab"))
{
    archive.Entries[0].Extract(httpResponseStream);
}

Exceptions

ArgumentException

destination’ does not support writing.

NotSupportedException

流动启动因错误数据而失败。

InvalidDataException

档案被腐败了。

Open()

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

public Stream Open()

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

 [NotSupportedException](https://learn.microsoft.com/dotnet/api/system.notsupportedexception)

Stream initialization failed due to wrong data.

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

The archive is corrupted.

### <a id="Aspose_Zip_Cab_CabEntry_ToString"></a> ToString\(\)

```csharp
public override string ToString()

Returns

string

 中文