Class WimFileEntry
Namespace: Aspose.Zip.Wim
Assembly: Aspose.Zip.dll (25.1.0)
表示 wim 存档中的单个文件。
public sealed class WimFileEntry : WimEntry, IArchiveFileEntry
继承
object ← WimEntry ← WimFileEntry
实现
继承成员
WimEntry.ToString(), WimEntry.Archive, WimEntry.Image, WimEntry.Parent, WimEntry.Name, WimEntry.ShortName, WimEntry.FullPath, WimEntry.ChangeTime, WimEntry.CreationTime, WimEntry.LastAccessTime, WimEntry.LastWriteTime, WimEntry.FileAttributes, WimEntry.AlternateDataStreams, WimEntry.HardLink, WimEntry.HasHardLinks, WimEntry.IsDirectory, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
属性
长度
获取条目的字节长度。
public long Length { get; }
属性值
方法
提取(string)
根据提供的路径将条目提取到文件系统中。
public FileInfo Extract(string path)
参数
path
string
目标文件的路径。如果文件已存在,将被覆盖。
返回
组合文件的信息。
示例
using (var archive = new WimArchive("archive.wim"))
{
archive.Images[0].RootDirectory.Files[0].Extract("data.bin");
}
异常
path
为 null。
调用者没有访问所需的权限。
path
为空,仅包含空格或包含无效字符。
访问文件 path
被拒绝。
指定的 path
、文件名或两者超出了系统定义的最大长度。例如,在基于 Windows 的平台上,路径必须少于 248 个字符,文件名必须少于 260 个字符。
path
中间包含冒号 (:)。
未找到文件。
指定的路径无效,例如位于未映射的驱动器上。
文件已打开。
存档已损坏。
提取(Stream)
将条目提取到提供的流中。
public void Extract(Stream destination)
参数
destination
Stream
目标流。必须可写。
示例
提取 wim 存档的条目。
using (var archive = new WimArchive("archive.wim"))
{
archive.Images[0].RootDirectory.Files[0].Extract(httpResponseStream);
}
异常
destination
不支持写入。
存档已损坏。
打开()
打开条目以进行提取并提供包含条目内容的流。
public Stream Open()
返回
表示条目内容的流。
示例
用法:
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>
#### 备注
从流中读取以获取文件的原始内容。请参见示例部分。