Class SevenZipArchiveEntry

Class SevenZipArchiveEntry

Namespace: Aspose.Zip.SevenZip
Assembly: Aspose.Zip.dll (25.1.0)

7zアーカイブ内の単一ファイルを表します。

public abstract class SevenZipArchiveEntry : IArchiveFileEntry

継承

objectSevenZipArchiveEntry

派生

SevenZipArchiveEntryEncrypted, SevenZipArchiveEntryPlain

実装

IArchiveFileEntry

継承メンバー

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

備考

Aspose.Zip.SevenZip.SevenZipArchiveEntryのインスタンスをAspose.Zip.SevenZip.SevenZipArchiveEntryEncryptedにキャストして、エントリが暗号化されているかどうかを判断します。

コンストラクタ

SevenZipArchiveEntry(SevenZipArchive, string, SevenZipCompressionSettings, Stream, FileAttributes, FileSystemInfo)

Aspose.Zip.SevenZip.SevenZipArchiveEntryクラスの新しいインスタンスを初期化します。

protected SevenZipArchiveEntry(SevenZipArchive parent, string name, SevenZipCompressionSettings compressionSettings, Stream source, FileAttributes fileAttributes, FileSystemInfo fileInfo = null)

パラメーター

parent SevenZipArchive

name string

エントリ名。

compressionSettings SevenZipCompressionSettings

圧縮または解凍の設定。

source Stream

圧縮または解凍されるエントリデータを含むストリーム。

fileAttributes FileAttributes

ファイルシステムからの属性。

fileInfo FileSystemInfo

エントリに基づくファイルまたはディレクトリ情報。

例外

ArgumentException

nameがnullまたは空です。

プロパティ

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; set; }

プロパティ値

Stream

UncompressedSize

元のファイルのサイズを取得します。

public ulong UncompressedSize { get; }

プロパティ値

ulong

メソッド

Extract(string, string)

指定されたパスにファイルシステムにエントリを抽出します。

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

パラメーター

path string

宛先ファイルへのパス。ファイルが既に存在する場合は上書きされます。

password string

復号化のためのオプションのパスワード。

戻り値

FileInfo

作成されたファイルの情報。

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

例外

ArgumentNullException

pathがnullです。

SecurityException

呼び出し元はアクセスするための必要な権限を持っていません。

ArgumentException

pathが空であるか、空白のみを含むか、無効な文字を含みます。

UnauthorizedAccessException

ファイルpathへのアクセスが拒否されました。

PathTooLongException

指定されたpath、ファイル名、またはその両方がシステム定義の最大長を超えています。たとえば、Windowsベースのプラットフォームでは、パスは248文字未満でなければならず、ファイル名は260文字未満でなければなりません。

NotSupportedException

path内にコロン(:)が含まれています。

InvalidDataException

アーカイブが破損しています。

Extract(Stream, string)

指定されたストリームにエントリを抽出します。

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

パラメーター

destination Stream

宛先ストリーム。書き込み可能でなければなりません。

password string

復号化のためのオプションのパスワード。

パスワード付きのzipアーカイブからエントリを抽出します。

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

例外

ArgumentException

destinationは書き込みをサポートしていません。

InvalidOperationException

アーカイブは抽出のために開かれていません。 - または - このエントリはディレクトリです。

InvalidDataException

エントリ内のデータが不正です。

FinalizeCompressedData(Stream, byte[])

圧縮データに続く任意のヘッダーを出力ストリームに書き込みます。

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

パラメーター

outputStream Stream

エントリの出力ストリーム。

encoderProperties byte[]

圧縮機のプロパティ。

戻り値

int

エントリの重要なデータブロックの後に追加された「技術的」バイトの数。

GetDestinationStream(Stream)

エントリの宛先ストリームであり、装飾される場合があります。

protected abstract Stream GetDestinationStream(Stream outputStream)

パラメーター

outputStream Stream

エントリの出力ストリーム。

戻り値

Stream

エントリ圧縮のための宛先ストリーム。

Open(string)

エントリを抽出のために開き、エントリコンテンツを持つストリームを提供します。

public Stream Open(string password = null)

パラメーター

password string

復号化のためのオプションのパスワード。

戻り値

Stream

エントリの内容を表すストリーム。

使用法: 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>

#### 備考

ストリームから読み取って、ファイルの元の内容を取得します。例のセクションを参照してください。

#### 例外

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

アーカイブは抽出のために開かれていません。 - または - このエントリはディレクトリです。

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

エントリ内のデータが不正です。

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

生のストリームの一部が圧縮されると発生します。

```csharp
public event EventHandler<progresseventargs> CompressionProgressed

イベントタイプ

EventHandler<ProgressEventArgs&gt;

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

備考

イベントの送信者はAspose.Zip.SevenZip.SevenZipArchiveEntryのインスタンスです。

LZMA2エントリに対してマルチスレッドモードでは呼び出されません。

 日本語