Class XarFileEntry
Namespace: Aspose.Zip.Xar
Assembly: Aspose.Zip.dll (25.1.0)
xar アーカイブ内のファイルエントリを表します。
public sealed class XarFileEntry : XarEntry, IArchiveFileEntry
継承
object ← XarEntry ← XarFileEntry
実装
継承されたメンバー
XarEntry.ToString(), XarEntry.Name, XarEntry.FullPath, XarEntry.IsDirectory, XarEntry.Parent, XarEntry.CreationTime, XarEntry.LastAccessTime, XarEntry.LastWriteTime, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
プロパティ
Length
エントリのバイト数を取得します。
public long Length { get; }
プロパティ値
メソッド
Extract(string)
指定されたパスにエントリをファイルシステムに抽出します。
public FileInfo Extract(string path)
パラメータ
path
string
宛先ファイルのパス。ファイルが既に存在する場合、上書きされます。
戻り値
生成されたファイルの情報。
例
using (var archive = new XarArchive("archive.xar"))
{
((XarFileEntry)archive.Entries[0]).Extract("data.bin");
}
例外
path
が null です。
呼び出し元にアクセスするための必要な権限がありません。
path
が空であるか、空白のみを含むか、無効な文字を含んでいます。
ファイル path
へのアクセスが拒否されました。
指定された path
、ファイル名、またはその両方がシステム定義の最大長を超えています。たとえば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満である必要があります。
path
に文字列の中間にコロン (:) が含まれています。
アーカイブが破損しています。
Extract(Stream)
指定されたストリームにエントリを抽出します。
public void Extract(Stream destination)
パラメータ
destination
Stream
宛先ストリーム。書き込み可能でなければなりません。
例
xar アーカイブのエントリを抽出します。
using (var archive = new XarArchive("archive.xar"))
{
((XarFileEntry)archive.Entries[0]).Extract(httpResponseStream);
}
例外
destination
は書き込みをサポートしていません。
アーカイブが破損しています。
Open()
エントリを抽出用に開き、エントリの内容を含むストリームを提供します。
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>
#### 備考
ストリームから読み取って、ファイルの元の内容を取得します。例のセクションを参照してください。
### <a id="Aspose_Zip_Xar_XarFileEntry_CompressionProgressed"></a> CompressionProgressed
生のストリームの一部が圧縮されたときに発生します。
```csharp
public event EventHandler<progresseventargs> CompressionProgressed
イベントタイプ
EventHandler<ProgressEventArgs>
例
archive.Entries.First().CompressionProgressed += (s, e) => { int percent = (int)((100 * (long)e.ProceededBytes) / entrySourceStream.Length); };
備考
イベントの送信者は Aspose.Zip.Xar.XarFileEntry インスタンスです。