Class SharArchive
名称: Aspose.Zip.Shar 組み合わせ: Aspose.Zip.dll (25.5.0)
このクラスは、鋭いファイルを表しています。
public class SharArchive : IDisposable
Inheritance
Implements
相続人
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
SharArchive()
Aspose.Zip.Shar.SharArchiveクラスの新しい例を開始します。
public SharArchive()
Examples
下記の例では、ファイルを圧縮する方法を示しています。
using (var archive = new SharArchive())
{
archive.CreateEntry("first.bin", "data.bin");
archive.Save("archive.shar");
}
SharArchive(ストレッチ)
Aspose.Zip.Shar.Sharアーカイブクラスの新しい例を開始し、デコンプレッシャーに備えています。
public SharArchive(string path)
Parameters
path
string
アーカイブのソースへの道
Exceptions
path’ is null.
通話者には、必要なアクセス許可はありません。
path’ は空っぽで、白いスペースのみが含まれ、または無効な文字が含まれています。
path" ファイルへのアクセスは拒否されます。
指定された path’, ファイル名, または両方ともシステム定義の最大長さを超えています. たとえば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
path’ のファイルには、列の真ん中のコロン(:)が含まれています。
ファイルは見つかりません。
指定されたルートは無効です、例えば、マッピングされていないドライブにあります。
ファイルはすでに開いています。
Properties
Entries
ファイルを構成する Aspose.Zip.Shar.SharEntry タイプの入力を受け取ります。
public ReadOnlyCollection<sharentry> Entries { get; }
不動産価値
ReadOnlyCollection < SharEntry >
Methods
CreateEntries(ボール、ボール)
アーカイブにすべてのファイルとディレクトリを繰り返し追加します。
public SharArchive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)
Parameters
sourceDirectory
string
コンプレッシャーディレクトリ
includeRootDirectory
bool
ルートディレクトリ自体を含むか否かを示す。
Returns
入り口の入り口。
Examples
using (FileStream sharFile = File.Open("archive.shar", FileMode.Create))
{
using (var archive = new SharArchive())
{
archive.CreateEntries("C:\folder", false);
archive.Save(sharFile);
}
}
Exceptions
sourceDirectory’ is null.
呼び出し者は、 sourceDirectory にアクセスするために必要な許可はありません。
sourceDirectory’ contains invalid characters such as “, <, >, or |.
例えば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
sourceDirectory’ stands for a file, not for a directory.
CreateEntries(ディレクトリ情報、ボール)
アーカイブにすべてのファイルとディレクトリを繰り返し追加します。
public SharArchive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)
Parameters
directory
DirectoryInfo
コンプレッシャーディレクトリ
includeRootDirectory
bool
ルートディレクトリ自体を含むか否かを示す。
Returns
入り口の入り口。
Examples
using (FileStream sharFile = File.Open("archive.shar", FileMode.Create))
{
using (var archive = new SharArchive())
{
archive.CreateEntries(new DirectoryInfo("C:\folder"), false);
archive.Save(sharFile);
}
}
Exceptions
directory’ is null.
通話者は、コードクラス=“paramref”>ディレクトリにアクセスするために必要な許可はありません。
directory’ stands for a file, not for a directory.
CreateEntry(ストリップ、ファイルインフォ、ボール)
ファイル内で単一のエントリーを作成します。
public SharEntry CreateEntry(string name, FileInfo fileInfo, bool openImmediately = false)
Parameters
name
string
入り口の名前。
fileInfo
FileInfo
ファイルまたはフォルダーのメタデータが圧縮される。
openImmediately
bool
確かに、すぐにファイルを開く場合は、ファイルをアーカイブ保存で開きます。
Returns
入り口の入り口。
Examples
FileInfo fileInfo = new FileInfo("data.bin");
using (var archive = new SharArchive())
{
archive.CreateEntry("test.bin", fileInfo);
archive.Save("archive.shar");
}
Remarks
ファイルがパラメーターで直ちに開く場合は、アーカイブが解除されるまでブロックされます。
Exceptions
name’ is null.
name’ is empty.
fileInfo’ is null.
CreateEntry(ストリップ、ストリップ、ボール)
ファイル内で単一のエントリーを作成します。
public SharEntry CreateEntry(string name, string sourcePath, bool openImmediately = false)
Parameters
name
string
入り口の名前。
sourcePath
string
ファイルを圧縮する方法
openImmediately
bool
確かに、すぐにファイルを開く場合は、ファイルをアーカイブ保存で開きます。
Returns
入り口の入り口。
Examples
using (var archive = new SharArchive())
{
archive.CreateEntry("first.bin", "data.bin");
archive.Save("archive.shar");
}
Remarks
入力名はパラメーター内でのみ設定されます. パラメーターで提供されたファイル名は、入力名に影響を与えません。
ファイルがパラメーターで直ちに開く場合は、アーカイブが解除されるまでブロックされます。
Exceptions
sourcePath’ is null.
通話者には、必要なアクセス許可はありません。
sourcePath’ は空っぽで、白いスペースのみが含まれ、または無効な文字が含まれています. - または - ファイル名は、
name’ の部分として、100 シンボルを超えています。
ファイルへのアクセス sourcePath’ は拒否されます。
例えば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
sourcePath’ のファイルには、列の真ん中のコロン(:)が含まれています。
CreateEntry(ストリーム、ストリーム)
ファイル内で単一のエントリーを作成します。
public SharEntry CreateEntry(string name, Stream source)
Parameters
name
string
入り口の名前。
source
Stream
入り口への入り口の流れ
Returns
入り口の入り口。
Examples
using (var archive = new SharArchive())
{
archive.CreateEntry("data.bin", File.OpenRead("data.bin"));
archive.Save("archive.shar");
}
Exceptions
name’ is null.
source’ is null.
name’ is empty.
DeleteEntry(SharEntry)
入力リストから特定の入力の最初の発生を削除します。
public SharArchive DeleteEntry(SharEntry entry)
Parameters
entry
SharEntry
入力リストから削除するための入力。
Returns
入り口の入り口。
Examples
以下は、最後の1を除くすべての投稿を削除する方法です。
using (var archive = new SharArchive("archive.shar"))
{
while (archive.Entries.Count > 1)
archive.DeleteEntry(archive.Entries[0]);
archive.Save(outputSharFile);
}
Exceptions
entry’ is null.
DeleteEntry(インタ)
入力リストからインデックスで入力を削除します。
public SharArchive DeleteEntry(int entryIndex)
Parameters
entryIndex
int
ゼロベースの入力インデックスを削除します。
Returns
エントリーを含むアーカイブが削除されました。
Examples
using (var archive = new SharArchive("two_files.shar"))
{
archive.DeleteEntry(0);
archive.Save("single_file.shar");
}
Exceptions
entryIndex’ is less than 0.-or-
entryIndex’ is equal to or greater than ‘Entries’ count.
Dispose(ボール)
応用によって定義された課題を実行し、未管理資源のリリース、リリース、またはリセットに関連しています。
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
管理された資源は削除されるべきである。
Dispose()
応用によって定義された課題を実行し、未管理資源のリリース、リリース、またはリセットに関連しています。
public void Dispose()
Save(ストレッチ)
提供された目的地ファイルにアーカイブを保存します。
public void Save(string destinationFileName)
Parameters
destinationFileName
string
ファイル名が既存のファイルを指定した場合、それは書き換えられます。
Examples
using (var archive = new SharArchive())
{
archive.CreateEntry("entry1", "data.bin");
archive.Save("archive.shar");
}
Remarks
しかし、このアプローチは一時的なファイルにコピーを使用しているため、これは推奨されていません。
Exceptions
destinationFileName’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.
destinationFileName’ is null.
指定された destinationFileName、ファイル名、または両方がシステムによって定義された最大長さを超える。例えば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。
指定された destinationFileName’ は無効です(例えば、マッピングされていないドライブにあります)。
ファイルを開く際に I/O エラーが発生しました。
destinationFileName’ specified a file that is read-only and access is not Read.-or- path specified a directory.-or- The caller does not have the required permission.
destinationFileName’ is in an invalid format.
ファイルは見つかりません。
Save(Stream)
提供されたストリームにアーカイブを保存します。
public void Save(Stream output)
Parameters
output
Stream
目的地の流れ
Examples
using (FileStream sharFile = File.Open("archive.shar", FileMode.Create))
{
using (var archive = new SharArchive())
{
archive.CreateEntry("entry1", "data.bin");
archive.Save(sharFile);
}
}
Remarks
書くべきである。
Exceptions
output’ is null.
output’ is not writable. - or -
output’ is the same stream we extract from.