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.SharArchive ที่เตรียมพร้อมสําหรับการบีบอัด

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(DirectoryInfo, บอล)

เพิ่มไฟล์และไดเรกทอรีทั้งหมดในไดเรกทอรี

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

ผู้โทรไม่ได้รับอนุญาตที่จําเป็นในการเข้าถึง directory”.

IOException

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

CreateEntry(ลวด, FileInfo, Bool)

สร้างรายการเดียวภายในเอกสาร

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

Parameters

name string

ชื่อของรายการ

fileInfo FileInfo

metadata ของไฟล์หรือโฟลเดอร์ที่จะถูกบีบอัด

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(string, string, บอล)

สร้างรายการเดียวภายในเอกสาร

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

ระบุ sourcePath’, ชื่อไฟล์, หรือทั้งสองเกินความยาวสูงสุดที่กําหนดโดยระบบ ตัวอย่างเช่นบนแพลตฟอร์มที่ใช้ Windows, เส้นทางต้องมีน้อยกว่า 248 หมายเลขและชื่อไฟล์ต้องมีน้อยกว่า 260 หมายเลข - หรือ - name’ เป็นยาวเกินไปสําหรับ shar

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

นี่คือวิธีที่คุณสามารถลบรายการทั้งหมดยกเว้นครั้งสุดท้าย:

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(int)

ลบป้อนจากรายการป้อนโดย index

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’ เป็น invalid, (เช่นมันอยู่ในไดรฟ์ที่ไม่ได้วาด)

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.

 แบบไทย