Class SharArchive

Class SharArchive

名称: Aspose.Zip.Shar 組み合わせ: Aspose.Zip.dll (25.5.0)

このクラスは、鋭いファイルを表しています。

public class SharArchive : IDisposable

Inheritance

object SharArchive

Implements

IDisposable

相続人

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

ArgumentNullException

path’ is null.

SecurityException

通話者には、必要なアクセス許可はありません。

ArgumentException

path’ は空っぽで、白いスペースのみが含まれ、または無効な文字が含まれています。

UnauthorizedAccessException

path" ファイルへのアクセスは拒否されます。

PathTooLongException

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

NotSupportedException

path’ のファイルには、列の真ん中のコロン(:)が含まれています。

FileNotFoundException

ファイルは見つかりません。

DirectoryNotFoundException

指定されたルートは無効です、例えば、マッピングされていないドライブにあります。

IOException

ファイルはすでに開いています。

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

SharArchive

入り口の入り口。

Examples

using (FileStream sharFile = File.Open("archive.shar", FileMode.Create))
{
    using (var archive = new SharArchive())
    {
        archive.CreateEntries("C:\folder", false);
        archive.Save(sharFile);
    }
}

Exceptions

ArgumentNullException

sourceDirectory’ is null.

SecurityException

呼び出し者は、 sourceDirectory にアクセスするために必要な許可はありません。

ArgumentException

sourceDirectory’ contains invalid characters such as “, <, >, or |.

PathTooLongException

例えば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。

IOException

sourceDirectory’ stands for a file, not for a directory.

CreateEntries(ディレクトリ情報、ボール)

アーカイブにすべてのファイルとディレクトリを繰り返し追加します。

public SharArchive CreateEntries(DirectoryInfo directory, bool includeRootDirectory = true)

Parameters

directory DirectoryInfo

コンプレッシャーディレクトリ

includeRootDirectory bool

ルートディレクトリ自体を含むか否かを示す。

Returns

SharArchive

入り口の入り口。

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

ArgumentNullException

directory’ is null.

SecurityException

通話者は、コードクラス=“paramref”>ディレクトリにアクセスするために必要な許可はありません。

IOException

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

SharEntry

入り口の入り口。

Examples

FileInfo fileInfo = new FileInfo("data.bin");
using (var archive = new SharArchive())
{
    archive.CreateEntry("test.bin", fileInfo);
    archive.Save("archive.shar");
}

Remarks

ファイルがパラメーターで直ちに開く場合は、アーカイブが解除されるまでブロックされます。

Exceptions

ArgumentNullException

name’ is null.

ArgumentException

name’ is empty.

ArgumentNullException

fileInfo’ is null.

CreateEntry(ストリップ、ストリップ、ボール)

ファイル内で単一のエントリーを作成します。

public SharEntry CreateEntry(string name, string sourcePath, bool openImmediately = false)

Parameters

name string

入り口の名前。

sourcePath string

ファイルを圧縮する方法

openImmediately bool

確かに、すぐにファイルを開く場合は、ファイルをアーカイブ保存で開きます。

Returns

SharEntry

入り口の入り口。

Examples

using (var archive = new SharArchive())
{
    archive.CreateEntry("first.bin", "data.bin");
    archive.Save("archive.shar");
}

Remarks

入力名はパラメーター内でのみ設定されます. パラメーターで提供されたファイル名は、入力名に影響を与えません。

ファイルがパラメーターで直ちに開く場合は、アーカイブが解除されるまでブロックされます。

Exceptions

ArgumentNullException

sourcePath’ is null.

SecurityException

通話者には、必要なアクセス許可はありません。

ArgumentException

sourcePath’ は空っぽで、白いスペースのみが含まれ、または無効な文字が含まれています. - または - ファイル名は、 name’ の部分として、100 シンボルを超えています。

UnauthorizedAccessException

ファイルへのアクセス sourcePath’ は拒否されます。

PathTooLongException

例えば、Windows ベースのプラットフォームでは、パスは 248 文字未満で、ファイル名は 260 文字未満でなければなりません。

NotSupportedException

sourcePath’ のファイルには、列の真ん中のコロン(:)が含まれています。

CreateEntry(ストリーム、ストリーム)

ファイル内で単一のエントリーを作成します。

public SharEntry CreateEntry(string name, Stream source)

Parameters

name string

入り口の名前。

source Stream

入り口への入り口の流れ

Returns

SharEntry

入り口の入り口。

Examples

using (var archive = new SharArchive())
{
    archive.CreateEntry("data.bin", File.OpenRead("data.bin"));
    archive.Save("archive.shar");
}

Exceptions

ArgumentNullException

name’ is null.

ArgumentNullException

source’ is null.

ArgumentException

name’ is empty.

DeleteEntry(SharEntry)

入力リストから特定の入力の最初の発生を削除します。

public SharArchive DeleteEntry(SharEntry entry)

Parameters

entry SharEntry

入力リストから削除するための入力。

Returns

SharArchive

入り口の入り口。

Examples

以下は、最後の1を除くすべての投稿を削除する方法です。

using (var archive = new SharArchive("archive.shar"))
{
    while (archive.Entries.Count &gt; 1)
        archive.DeleteEntry(archive.Entries[0]);
    archive.Save(outputSharFile);
}

Exceptions

ArgumentNullException

entry’ is null.

DeleteEntry(インタ)

入力リストからインデックスで入力を削除します。

public SharArchive DeleteEntry(int entryIndex)

Parameters

entryIndex int

ゼロベースの入力インデックスを削除します。

Returns

SharArchive

エントリーを含むアーカイブが削除されました。

Examples

using (var archive = new SharArchive("two_files.shar"))
{
    archive.DeleteEntry(0);
    archive.Save("single_file.shar");
}

Exceptions

ArgumentOutOfRangeException

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

ArgumentException

destinationFileName’ is a zero-length string, contains only white space, or contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.

ArgumentNullException

destinationFileName’ is null.

PathTooLongException

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

DirectoryNotFoundException

指定された destinationFileName’ は無効です(例えば、マッピングされていないドライブにあります)。

IOException

ファイルを開く際に I/O エラーが発生しました。

UnauthorizedAccessException

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.

NotSupportedException

destinationFileName’ is in an invalid format.

FileNotFoundException

ファイルは見つかりません。

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

ArgumentNullException

output’ is null.

ArgumentException

output’ is not writable. - or - output’ is the same stream we extract from.

 日本語