Class SevenZipArchive
名称: Aspose.Zip.SevenZip 組み合わせ: Aspose.Zip.dll (25.5.0)
このクラスは7zアーカイブファイルを表します. 7zアーカイブを構成および抽出するために使用します。
public class SevenZipArchive : IArchive, IDisposable
Inheritance
Implements
相続人
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
SevenZipArchive(SevenZipEntrySettings)
Aspose.Zip.SevenZip.SevenZipArchive クラスの新しいインスタンスをオプション設定で開始します。
public SevenZipArchive(SevenZipEntrySettings newEntrySettings = null)
Parameters
newEntrySettings
SevenZipEntrySettings
新しく追加された Aspose.Zip.SevenZip.SevenZipArchiveEntry アイテムに使用された圧縮および暗号化設定。指定されていない場合は、暗号化なしのLZMA圧縮が使用されます。
Examples
下記の例では、デフォルト設定で単一のファイルを圧縮する方法を示しています:暗号化なしでLZMA圧缩。
using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
using (var archive = new SevenZipArchive())
{
archive.CreateEntry("data.bin", "file.dat");
archive.Save(sevenZipFile);
}
}
SevenZipArchive(ストリーム、ストリーム)
Aspose.Zip.SevenZip.SevenZipArchive クラスの新しい例を開始し、アーカイブから抽出できる入力リストを構成します。
public SevenZipArchive(Stream sourceStream, string password = null)
Parameters
sourceStream
Stream
アーカイブの源です。
password
string
暗号化のためのオプションパスワード. ファイル名が暗号化されている場合、それは存在する必要があります。
Examples
using (SevenZipArchive archive = new SevenZipArchive(File.OpenRead("archive.7z")))
{
archive.ExtractToDirectory("C:\\extracted");
}
Remarks
Aspose.Zip.SevenZip.SevenZipArchive.ExtractToDirectory(System.String、System.String)のデコンプレッシャー方法を参照してください。
Exceptions
sourceStream’ is not seekable.
sourceStream’ is null.
アーカイブには複数のコーダーが含まれています. 現在、LZMAの圧縮だけがサポートされています。
SevenZipArchive(ストリップ、ストリップ)
Aspose.Zip.SevenZip.SevenZipArchive クラスの新しい例を開始し、アーカイブから抽出できる入力リストを構成します。
public SevenZipArchive(string path, string password = null)
Parameters
path
string
完全に資格あるいはアーカイブファイルへの相対的なルート。
password
string
暗号化のためのオプションパスワード. ファイル名が暗号化されている場合、それは存在する必要があります。
Examples
using (SevenZipArchive archive = new SevenZipArchive("archive.7z"))
{
archive.ExtractToDirectory("C:\\extracted");
}
Remarks
Aspose.Zip.SevenZip.SevenZipArchive.ExtractToDirectory(System.String、System.String)のデコンプレッシャー方法を参照してください。
Exceptions
path’ is null.
通話者には、必要なアクセス許可はありません。
path’ は空っぽで、白いスペースのみが含まれ、または無効な文字が含まれています。
path" ファイルへのアクセスは拒否されます。
指定された path’, ファイル名, または両方ともシステム定義の最大長さを超えています. たとえば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
path’ のファイルには、列の真ん中のコロン(:)が含まれています。
ファイルは見つかりません。
指定されたルートは無効です、例えば、マッピングされていないドライブにあります。
ファイルはすでに開いています。
SevenZipArchive(ストレッチ( ), ストリップ)
Aspose.Zip.SevenZip.SevenZipアーカイブクラスの新しい例を複数ボリューム7zアーカイブから開始し、アーカイブから抽出できる入力リストを構成します。
public SevenZipArchive(string[] parts, string password = null)
Parameters
parts
string
( )
各セグメントの複数ボリューム7zアーカイブに順序を満たす方法
password
string
暗号化のためのオプションパスワード. ファイル名が暗号化されている場合、それは存在する必要があります。
Examples
using (SevenZipArchive archive = new SevenZipArchive(new string[] { "multi.7z.001", "multi.7z.002", "multi.7z.003" }))
{
archive.ExtractToDirectory("C:\\extracted");
}
Exceptions
parts’ is null.
parts’ has no entries.
通話者には、必要なアクセス許可はありません。
ファイルへの道は空っぽで、白いスペースのみが含まれ、または無効な文字が含まれています。
ファイルへのアクセスは拒否されます。
例えば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
コースのファイルには、列の真ん中のコロン(:)が含まれています。
Properties
Entries
Aspose.Zip.SevenZip.SevenZipArchiveEntry の入力がアーカイブを構成します。
public ReadOnlyCollection<sevenziparchiveentry> Entries { get; }
不動産価値
ReadOnlyCollection < SevenZipArchiveEntry >
NewEntrySettings
新しく追加された Aspose.Zip.SevenZip.SevenZipArchiveEntry アイテムに使用された圧縮および暗号化設定。
public SevenZipEntrySettings NewEntrySettings { get; }
不動産価値
Methods
CreateEntries(ディレクトリ情報、ボール)
アーカイブにすべてのファイルやディレクトリを、指定されたディレクトリに再度追加します。
public SevenZipArchive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)
Parameters
directory
DirectoryInfo
コンプレッシャーディレクトリ
includeRootDirectory
bool
ルートディレクトリ自体を含むか否かを示す。
Returns
アーカイブで構成されたエントリー
Examples
using (SevenZipArchive archive = new SevenZipArchive())
{
DirectoryInfo folder = new DirectoryInfo("C:\folder");
archive.CreateEntries(folder);
archive.Save("folder.7z");
}
Exceptions
directory’ へのルートは、例えば、マッピングされていないドライブにいるように、無効です。
通話者は、コードクラス=“paramref”>ディレクトリにアクセスするために必要な許可はありません。
CreateEntries(ボール、ボール)
アーカイブにすべてのファイルやディレクトリを、指定されたディレクトリに再度追加します。
public SevenZipArchive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)
Parameters
sourceDirectory
string
コンプレッシャーディレクトリ
includeRootDirectory
bool
ルートディレクトリ自体を含むか否かを示す。
Returns
アーカイブで構成されたエントリー
Examples
7z アーカイブを LZMA2 圧縮で構成します。
using (SevenZipArchive archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMACompressionSettings())))
{
archive.CreateEntries("C:\folder");
archive.Save("folder.7z");
}
CreateEntry(ストリップ, FileInfo, bool, SevenZipEntrySettings)
ファイル内で単一のエントリーを作成します。
public SevenZipArchiveEntry CreateEntry(string name, FileInfo fileInfo, bool openImmediately = false, SevenZipEntrySettings newEntrySettings = null)
Parameters
name
string
入り口の名前。
fileInfo
FileInfo
ファイルのメタデータが圧縮されます。
openImmediately
bool
確かに、すぐにファイルを開く場合は、ファイルをアーカイブ保存で開きます。
newEntrySettings
SevenZipEntrySettings
Aspose.Zip.SevenZip.SevenZipArchiveEntry を追加するために使用される圧縮および暗号化設定。
Returns
7 ZIP 入り口
Examples
各パスワードで暗号化されたエントリーを含むアーカイブを構成します。
using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
FileInfo fi1 = new FileInfo("data1.bin");
FileInfo fi2 = new FileInfo("data2.bin");
FileInfo fi3 = new FileInfo("data3.bin");
using (var archive = new SevenZipArchive())
{
archive.CreateEntry("entry1.bin", fi1, false, new SevenZipEntrySettings(new SevenZipStoreCompressionSettings(), new SevenZipAESEncryptionSettings("test1")));
archive.CreateEntry("entry2.bin", fi2, false, new SevenZipEntrySettings(new SevenZipStoreCompressionSettings(), new SevenZipAESEncryptionSettings("test2")));
archive.CreateEntry("entry3.bin", fi3, false, new SevenZipEntrySettings(new SevenZipStoreCompressionSettings(), new SevenZipAESEncryptionSettings("test3")));
archive.Save(sevenZipFile);
}
}
Remarks
入力名はパラメーター内でのみ設定されます. パラメーターで提供されたファイル名は、入力名に影響を与えません。
ファイルがパラメーターで直ちに開くと、アーカイブが保存されるまでブロックされます。
Exceptions
fileInfo’ is read-only or is a directory.
指定されたルートは無効です、例えば、マッピングされていないドライブにあります。
ファイルはすでに開いています。
CreateEntry(ストリーム, ストリーム, SevenZipEntrySettings, FileSystemInfo)
ファイル内で単一のエントリーを作成します。
public SevenZipArchiveEntry CreateEntry(string name, Stream source, SevenZipEntrySettings newEntrySettings, FileSystemInfo fileInfo)
Parameters
name
string
入り口の名前。
source
Stream
入り口への入り口の流れ
newEntrySettings
SevenZipEntrySettings
Aspose.Zip.SevenZip.SevenZipArchiveEntry を追加するために使用される圧縮および暗号化設定。
fileInfo
FileSystemInfo
ファイルまたはフォルダーのメタデータが圧縮される。
Returns
7ZIP入場例
Examples
LZMA2 圧縮された暗号化された入力でアーカイブを組み合わせる。
using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
using (var archive = new SevenZipArchive())
{
archive.CreateEntry("entry1.bin", new MemoryStream(new byte[] {0x00, 0xFF}), new SevenZipEntrySettings(new SevenZipLZMA2CompressionSettings(), new SevenZipAESEncryptionSettings("test1")), new FileInfo("data1.bin"));
archive.Save(sevenZipFile);
}
}
Remarks
入力名はパラメーター内でのみ設定されます. パラメーターで提供されたファイル名は、入力名に影響を与えません。
System.IO.DirectoryInfo に参照できる場合、入力はディレクトリです。
Exceptions
source’ and
fileInfo’ are null or
source’ is null and
fileInfo’ stands for directory.
fileInfo’ is null or
source’ is null and
fileInfo’ stands for directory.
CreateEntry(ストリーム、ストリーム、7ZipEntrySettings)
ファイル内で単一のエントリーを作成します。
public SevenZipArchiveEntry CreateEntry(string name, Stream source, SevenZipEntrySettings newEntrySettings = null)
Parameters
name
string
入り口の名前。
source
Stream
入り口への入り口の流れ
newEntrySettings
SevenZipEntrySettings
Aspose.Zip.SevenZip.SevenZipArchiveEntry を追加するために使用される圧縮および暗号化設定。
Returns
ZIP 入り口
Examples
LZMA2の圧縮とすべてのエントリーの暗号化を含む7zアーカイブを構成します。
using (var archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMA2CompressionSettings(), new SevenZipAESEncryptionSettings("p@s$"))))
{
archive.CreateEntry("data.bin", new MemoryStream(new byte[] {0x00, 0xFF} ));
archive.Save("archive.7z");
}
CreateEntry(ストリップ、ストリップ、ボール、SevenZipEntrySettings)
ファイル内で単一のエントリーを作成します。
public SevenZipArchiveEntry CreateEntry(string name, string path, bool openImmediately = false, SevenZipEntrySettings newEntrySettings = null)
Parameters
name
string
入り口の名前。
path
string
新しいファイルの完全に資格のある名前、または圧縮される相対ファイル名。
openImmediately
bool
確かに、すぐにファイルを開く場合は、ファイルをアーカイブ保存で開きます。
newEntrySettings
SevenZipEntrySettings
Aspose.Zip.SevenZip.SevenZipArchiveEntry を追加するために使用される圧縮および暗号化設定。
Returns
ZIP 入り口
Examples
using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
using (var archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMA2CompressionSettings())))
{
archive.CreateEntry("data.bin", "file.dat");
archive.Save(sevenZipFile);
}
}
Remarks
入力名はパラメーター内でのみ設定されます. パラメーターで提供されたファイル名は、入力名に影響を与えません。
ファイルがパラメーターで直ちに開くと、アーカイブが保存されるまでブロックされます。
Exceptions
path’ is null.
通話者には、必要なアクセス許可はありません。
path’ は空っぽで、白いスペースのみが含まれ、または無効な文字が含まれています。
path" ファイルへのアクセスは拒否されます。
指定された path’, ファイル名, または両方ともシステム定義の最大長さを超えています. たとえば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
path’ のファイルには、列の真ん中のコロン(:)が含まれています。
Dispose()
応用によって定義された課題を実行し、未管理資源のリリース、リリース、またはリセットに関連しています。
public void Dispose()
Dispose(ボール)
応用によって定義された課題を実行し、未管理資源のリリース、リリース、またはリセットに関連しています。
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
管理された資源は削除されるべきである。
ExtractToDirectory(ストリップ、ストリップ)
アーカイブのすべてのファイルを提供されたディレクトリに抽出します。
public void ExtractToDirectory(string destinationDirectory, string password = null)
Parameters
destinationDirectory
string
引き出されたファイルを入力するためのディレクトリへのルート。
password
string
コンテンツの暗号化のためのオプションパスワード
Examples
using (var archive = new SevenZipArchive("archive.7z"))
{
archive.ExtractToDirectory("C:\extracted");
}
Remarks
ディレクトリが存在しない場合は、作成されます。
ファイル名が暗号化されている場合は、パスワードを Aspose.Zip.SevenZapArchive.#ctor(System.String、Systems. String)または __ WL51. Zip。
Exceptions
destinationDirectory’ is null.
例えば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
通話者は、既存のディレクトリにアクセスするための必要な許可はありません。
ディレクトリが存在しない場合、コースには、ドライブラベル(「C:」)の一部ではないコロン キャラクター(:)が含まれています。
destinationDirectory’ is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the System.IO.Path.GetInvalidPathChars method. -or- path is prefixed with, or contains, only a colon character (:).
ルートによって指定されたディレクトリはファイルです. -or- ネットワーク名は知られていません。
アーカイブが腐敗した。
Save(Stream)
7z アーカイブを提供されたストリームに保存します。
public void Save(Stream output)
Parameters
output
Stream
目的地の流れ
Examples
using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
using (var archive = new SevenZipArchive())
{
archive.CreateEntry("data", source);
archive.Save(sevenZipFile);
}
}
}
Remarks
求めるべきである。
Exceptions
output’ does not support seeking.
output’ is null.
コードはデータを圧縮できなかった。
Save(ストレッチ)
提供された目的地ファイルにアーカイブを保存します。
public void Save(string destinationFileName)
Parameters
destinationFileName
string
ファイル名が既存のファイルを指定した場合、それは書き換えられます。
Examples
using (FileStream source = File.Open("data.bin", FileMode.Open, FileAccess.Read))
{
using (var archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMACompressionSettings())))
{
archive.CreateEntry("data", source);
archive.Save("archive.7z");
}
}
Remarks
しかし、このアプローチは一時的なファイルにコピーを使用しているため、これは推奨されていません。
Exceptions
destinationFileName’ is null.
通話者には、必要なアクセス許可はありません。
destinationFileName’ は空っぽで、白いスペースのみが含まれ、または無効な文字が含まれています。
ファイルへのアクセス destinationFileName’ は拒否されます。
指定された destinationFileName、ファイル名、または両方がシステムによって定義された最大長さを超える。例えば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
ファイル destinationFileName’ には、列の真ん中のコロン(:)が含まれています。
SaveSplit(ストレッチ, SplitSevenZipArchiveSaveOptions)
多量アーカイブを提供された目的地ディレクトリに保存します。
public void SaveSplit(string destinationDirectory, SplitSevenZipArchiveSaveOptions options)
Parameters
destinationDirectory
string
アーカイブセグメントが作成されるディレクトリへのルート。
options
SplitSevenZipArchiveSaveOptions
ファイル名を含むアーカイブ保存のオプション
Examples
using (SevenZipArchive archive = new SevenZipArchive())
{
archive.CreateEntry("entry.bin", "data.bin");
archive.SaveSplit(@"C:\Folder", new SplitSevenZipArchiveSaveOptions("volume", 65536));
}
Remarks
この方法は、複数の()ファイル filename.7z.001, filename.7z.002, …, filename.7z.(n)を構成します。
既存のアーカイブの多量を作成することはできません。
Exceptions
このアーカイブは既存のソースから開かれました。
destinationDirectory’ is null.
通話者は、ディレクトリにアクセスするために必要な許可はありません。
destinationDirectory’ contains invalid characters such as “, >, <, or |.
指定されたルートは、システムによって定義された最大長さを超える。