Class RarArchiveEntry
名称: Aspose.Zip.Rar 收藏: Aspose.Zip.dll (25.5.0)
代表单个文件在档案中。
public abstract class RarArchiveEntry : IArchiveFileEntry
Inheritance
Derived
RarArchiveEntryEncrypted , RarArchiveEntryPlain
Implements
继承人
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Remarks
插入 Aspose.Zip.Rar.RarArchiveEntry 示例到 Aspose.Zip.Rar.RarArchiveEntry 加密,以确定输入是否加密。
Properties
CompressedSize
收到压缩文件的尺寸。
public ulong CompressedSize { get; }
财产价值
CreationTime
创造的日期和时间。
public DateTime CreationTime { get; }
财产价值
IsDirectory
收到一个值,表明输入是否代表一个目录。
public bool IsDirectory { get; }
财产价值
LastAccessTime
获取最后访问日期和时间。
public DateTime LastAccessTime { get; }
财产价值
ModificationTime
收到最后修改的日期和时间。
public DateTime ModificationTime { get; }
财产价值
Name
收到存档中的输入名称。
public string Name { get; }
财产价值
Source
获取输入的数据源流。
protected Stream Source { get; set; }
财产价值
UncompressedSize
得到原始文件的尺寸。
public ulong UncompressedSize { get; }
财产价值
Methods
Extract(字符串, string)
通过提供的路径将输入到文件系统。
public FileInfo Extract(string path, string password = null)
Parameters
path
string
路径到目的地文件. 如果文件已经存在,它将被过写。
password
string
可选的密码来解密。
Returns
组成文件的文件信息。
Examples
提取RAR档案的两个输入。
using (FileStream rarFile = File.Open("archive.rar", FileMode.Open))
{
using (RarArchive archive = new RarArchive(rarFile))
{
archive.Entries[0].Extract("first.bin", "pass");
archive.Entries[1].Extract("second.bin", "pass");
}
}
Exceptions
path’ is null.
召唤者没有所需的访问许可。
path’ 是空的,只包含白色空间,或包含无效的字符。
拒绝访问 path" 文件。
指定的 path’, 文件名, 或两者都超过系统定义的最大长度. 例如,在基于 Windows 的平台上,路径必须小于 248 个字符, 文件名必须小于 260 个字符。
文件在 path’ 中间包含一个列(:)。
文件未找到。
指定的路径是无效的,例如在无地图驱动器上。
文件已经开放了。
数据被破坏 - 或 - CRC 或 MAC 验证失败了输入。
Extract(流, string)
将输入到提供的流。
public void Extract(Stream destination, string password = null)
Parameters
destination
Stream
目的地流,必须写作。
password
string
可选的密码来解密。
Examples
用密码提取一个 rar 档案的输入。
using (FileStream rarFile = File.Open("archive.zip", FileMode.Open))
{
using (RarArchive archive = new RarArchive(rarFile))
{
archive.Entries[0].Extract(httpResponseStream, "p@s$");
}
}
Exceptions
CRC 或 MAC 验证失败了输入。
destination’ does not support writing.
数据被破坏 - 或 - CRC 或 MAC 验证失败了输入。
Open(线条)
打开输入用于提取,并提供压缩输入内容的流量。
public Stream Open(string password = null)
Parameters
password
string
可选的密码解密. 它也可以在 Aspose.Zip.Rar.RarArchiveLoadOptions.DecryptionPassword 中设置。
Returns
代表入口内容的流。
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
<p>Read from the stream to get the original content of a file. See examples section.</p>
### <a id="Aspose_Zip_Rar_RarArchiveEntry_ExtractionProgressed"></a> ExtractionProgressed
Raises when a portion of raw stream extracted.
```csharp
public event EventHandler<progresseventargs> ExtractionProgressed
事件类型
EventHandler < ProgressEventArgs >
Examples
archive.Entries[0].ExtractionProgressed += (s, e) => { int percent = (int)((100 * e.ProceededBytes) / ((RarArchiveEntry)s).UncompressedSize); };
Remarks
事件发送器是一个 Aspose.Zip.Rar.RarArchiveEntry 例子。