Class SevenZipArchive

Class SevenZipArchive

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

คลาสนี้แทนที่ไฟล์บีบอัด 7z ใช้เพื่อสร้างและแยกไฟล์บีบอัด 7z

public class SevenZipArchive : IArchive, IDisposable

การสืบทอด

objectSevenZipArchive

การใช้งาน

IArchive, IDisposable

สมาชิกที่สืบทอด

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

ตัวสร้าง

SevenZipArchive(SevenZipEntrySettings)

เริ่มต้นอินสแตนซ์ใหม่ของคลาส Aspose.Zip.SevenZip.SevenZipArchive โดยมีการตั้งค่าสำหรับรายการที่เลือก

public SevenZipArchive(SevenZipEntrySettings newEntrySettings = null)

พารามิเตอร์

newEntrySettings SevenZipEntrySettings

การตั้งค่าการบีบอัดและการเข้ารหัสที่ใช้สำหรับรายการ Aspose.Zip.SevenZip.SevenZipArchiveEntry ที่เพิ่มใหม่ หากไม่ได้ระบุ จะใช้การบีบอัด LZMA โดยไม่มีการเข้ารหัส

ตัวอย่าง

ตัวอย่างต่อไปนี้แสดงวิธีการบีบอัดไฟล์เดียวด้วยการตั้งค่าเริ่มต้น: การบีบอัด 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(Stream, string)

เริ่มต้นอินสแตนซ์ใหม่ของคลาส Aspose.Zip.SevenZip.SevenZipArchive และสร้างรายการที่สามารถแยกออกจากไฟล์บีบอัดได้

public SevenZipArchive(Stream sourceStream, string password = null)

พารามิเตอร์

sourceStream Stream

แหล่งที่มาของไฟล์บีบอัด

password string

รหัสผ่านสำหรับการถอดรหัส หากชื่อไฟล์ถูกเข้ารหัส จะต้องมีอยู่

ตัวอย่าง

using (SevenZipArchive archive = new SevenZipArchive(File.OpenRead("archive.7z")))
{
    archive.ExtractToDirectory("C:\\extracted");
}

หมายเหตุ

ตัวสร้างนี้จะไม่ทำการแยกไฟล์ใด ๆ ดูวิธี Aspose.Zip.SevenZip.SevenZipArchive.ExtractToDirectory(System.String,System.String) สำหรับการแยกไฟล์

ข้อยกเว้น

ArgumentException

sourceStream ไม่สามารถค้นหาได้

ArgumentNullException

sourceStream เป็น null

NotImplementedException

ไฟล์บีบอัดมีมากกว่าหนึ่งตัวเข้ารหัส ขณะนี้รองรับเฉพาะการบีบอัด LZMA เท่านั้น

SevenZipArchive(string, string)

เริ่มต้นอินสแตนซ์ใหม่ของคลาส Aspose.Zip.SevenZip.SevenZipArchive และสร้างรายการที่สามารถแยกออกจากไฟล์บีบอัดได้

public SevenZipArchive(string path, string password = null)

พารามิเตอร์

path string

เส้นทางที่มีคุณสมบัติครบถ้วนหรือเส้นทางสัมพัทธ์ไปยังไฟล์บีบอัด

password string

รหัสผ่านสำหรับการถอดรหัส หากชื่อไฟล์ถูกเข้ารหัส จะต้องมีอยู่

ตัวอย่าง

using (SevenZipArchive archive = new SevenZipArchive("archive.7z"))
{
    archive.ExtractToDirectory("C:\\extracted");
}

หมายเหตุ

ตัวสร้างนี้จะไม่ทำการแยกไฟล์ใด ๆ ดูวิธี Aspose.Zip.SevenZip.SevenZipArchive.ExtractToDirectory(System.String,System.String) สำหรับการแยกไฟล์

ข้อยกเว้น

ArgumentNullException

path เป็น null

SecurityException

ผู้เรียกไม่มีสิทธิ์เข้าถึงที่จำเป็น

ArgumentException

path ว่างเปล่า มีเฉพาะช่องว่าง หรือมีอักขระที่ไม่ถูกต้อง

UnauthorizedAccessException

การเข้าถึงไฟล์ path ถูกปฏิเสธ

PathTooLongException

path ที่ระบุ ชื่อไฟล์ หรือทั้งสองอย่างเกินความยาวสูงสุดที่กำหนดโดยระบบ ตัวอย่างเช่น บนแพลตฟอร์มที่ใช้ Windows เส้นทางต้องมีความยาวน้อยกว่า 248 อักขระ และชื่อไฟล์ต้องมีความยาวน้อยกว่า 260 อักขระ

NotSupportedException

ไฟล์ที่ path มีเครื่องหมายทวิจารณ์ (:) อยู่กลางสตริง

FileNotFoundException

ไม่พบไฟล์

DirectoryNotFoundException

เส้นทางที่ระบุไม่ถูกต้อง เช่น อยู่ในไดรฟ์ที่ไม่ได้แมพ

IOException

ไฟล์เปิดอยู่แล้ว

SevenZipArchive(string[], string)

เริ่มต้นอินสแตนซ์ใหม่ของคลาส Aspose.Zip.SevenZip.SevenZipArchive จากไฟล์บีบอัด 7z หลายเล่มและสร้างรายการที่สามารถแยกออกจากไฟล์บีบอัดได้

public SevenZipArchive(string[] parts, string password = null)

พารามิเตอร์

parts string[]

เส้นทางไปยังแต่ละส่วนของไฟล์บีบอัด 7z หลายเล่มตามลำดับ

password string

รหัสผ่านสำหรับการถอดรหัส หากชื่อไฟล์ถูกเข้ารหัส จะต้องมีอยู่

ตัวอย่าง

using (SevenZipArchive archive = new SevenZipArchive(new string[] { "multi.7z.001", "multi.7z.002", "multi.7z.003" }))
{
    archive.ExtractToDirectory("C:\\extracted");
}

ข้อยกเว้น

ArgumentNullException

parts เป็น null

ArgumentException

parts ไม่มีรายการ

SecurityException

ผู้เรียกไม่มีสิทธิ์เข้าถึงที่จำเป็น

ArgumentException

เส้นทางไปยังไฟล์ว่างเปล่า มีเฉพาะช่องว่าง หรือมีอักขระที่ไม่ถูกต้อง

UnauthorizedAccessException

การเข้าถึงไฟล์ถูกปฏิเสธ

PathTooLongException

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

NotSupportedException

ไฟล์ที่เส้นทางมีเครื่องหมายทวิจารณ์ (:) อยู่กลางสตริง

คุณสมบัติ

Entries

ดึงรายการของประเภท Aspose.Zip.SevenZip.SevenZipArchiveEntry ที่สร้างขึ้นจากไฟล์บีบอัด

public ReadOnlyCollection<sevenziparchiveentry> Entries { get; }

ค่า Property

ReadOnlyCollection<SevenZipArchiveEntry&gt;

NewEntrySettings

การตั้งค่าการบีบอัดและการเข้ารหัสที่ใช้สำหรับรายการ Aspose.Zip.SevenZip.SevenZipArchiveEntry ที่เพิ่มใหม่

public SevenZipEntrySettings NewEntrySettings { get; }

ค่า Property

SevenZipEntrySettings

วิธีการ

CreateEntries(DirectoryInfo, bool)

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

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

พารามิเตอร์

directory DirectoryInfo

ไดเรกทอรีที่ต้องการบีบอัด

includeRootDirectory bool

ระบุว่าต้องการรวมไดเรกทอรีหลักเองหรือไม่

ส่งคืน

SevenZipArchive

ไฟล์บีบอัดที่มีรายการที่สร้างขึ้น

ตัวอย่าง

using (SevenZipArchive archive = new SevenZipArchive())
{
    DirectoryInfo folder = new DirectoryInfo("C:\folder");
    archive.CreateEntries(folder);
    archive.Save("folder.7z");
}

ข้อยกเว้น

DirectoryNotFoundException

เส้นทางไปยัง directory ไม่ถูกต้อง เช่น อยู่ในไดรฟ์ที่ไม่ได้แมพ

SecurityException

ผู้เรียกไม่มีสิทธิ์เข้าถึง directory ที่จำเป็น

CreateEntries(string, bool)

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

public SevenZipArchive CreateEntries(string sourceDirectory, bool includeRootDirectory = true)

พารามิเตอร์

sourceDirectory string

ไดเรกทอรีที่ต้องการบีบอัด

includeRootDirectory bool

ระบุว่าต้องการรวมไดเรกทอรีหลักเองหรือไม่

ส่งคืน

SevenZipArchive

ไฟล์บีบอัดที่มีรายการที่สร้างขึ้น

ตัวอย่าง

สร้างไฟล์บีบอัด 7z ด้วยการบีบอัด LZMA2

using (SevenZipArchive archive = new SevenZipArchive(new SevenZipEntrySettings(new SevenZipLZMACompressionSettings())))
{
    archive.CreateEntries("C:\folder");
    archive.Save("folder.7z");
}

CreateEntry(string, FileInfo, bool, SevenZipEntrySettings)

สร้างรายการเดียวภายในไฟล์บีบอัด

public SevenZipArchiveEntry CreateEntry(string name, FileInfo fileInfo, bool openImmediately = false, SevenZipEntrySettings newEntrySettings = null)

พารามิเตอร์

name string

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

fileInfo FileInfo

ข้อมูลเมตาของไฟล์ที่จะบีบอัด

openImmediately bool

เป็นจริงหากเปิดไฟล์ทันที มิฉะนั้นจะเปิดไฟล์เมื่อบันทึกไฟล์บีบอัด

newEntrySettings SevenZipEntrySettings

การตั้งค่าการบีบอัดและการเข้ารหัสที่ใช้สำหรับรายการ Aspose.Zip.SevenZip.SevenZipArchiveEntry ที่เพิ่ม

ส่งคืน

SevenZipArchiveEntry

อินสแตนซ์รายการ Seven Zip

ตัวอย่าง

สร้างไฟล์บีบอัดด้วยรายการที่เข้ารหัสด้วยรหัสผ่านที่แตกต่างกันแต่ละรายการ

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

หมายเหตุ

ชื่อรายการถูกตั้งค่าเฉพาะในพารามิเตอร์ name ชื่อไฟล์ที่ให้ในพารามิเตอร์ fileInfo ไม่มีผลต่อชื่อรายการ

หากไฟล์ถูกเปิดทันทีด้วยพารามิเตอร์ openImmediately จะถูกบล็อกจนกว่าไฟล์บีบอัดจะถูกบันทึก

ข้อยกเว้น

UnauthorizedAccessException

fileInfo เป็นแบบอ่านอย่างเดียวหรือเป็นไดเรกทอรี

DirectoryNotFoundException

เส้นทางที่ระบุไม่ถูกต้อง เช่น อยู่ในไดรฟ์ที่ไม่ได้แมพ

IOException

ไฟล์เปิดอยู่แล้ว

CreateEntry(string, Stream, SevenZipEntrySettings, FileSystemInfo)

สร้างรายการเดียวภายในไฟล์บีบอัด

public SevenZipArchiveEntry CreateEntry(string name, Stream source, SevenZipEntrySettings newEntrySettings, FileSystemInfo fileInfo)

พารามิเตอร์

name string

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

source Stream

สตรีมข้อมูลนำเข้าของรายการ

newEntrySettings SevenZipEntrySettings

การตั้งค่าการบีบอัดและการเข้ารหัสที่ใช้สำหรับรายการ Aspose.Zip.SevenZip.SevenZipArchiveEntry ที่เพิ่ม

fileInfo FileSystemInfo

ข้อมูลเมตาของไฟล์หรือโฟลเดอร์ที่จะบีบอัด

ส่งคืน

SevenZipArchiveEntry

อินสแตนซ์รายการ SevenZip

ตัวอย่าง

สร้างไฟล์บีบอัดที่มีรายการที่เข้ารหัสด้วย 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);
    }
}

หมายเหตุ

ชื่อรายการถูกตั้งค่าเฉพาะในพารามิเตอร์ name ชื่อไฟล์ที่ให้ในพารามิเตอร์ fileInfo ไม่มีผลต่อชื่อรายการ

fileInfo สามารถอ้างถึง System.IO.DirectoryInfo หากรายการเป็นไดเรกทอรี

ข้อยกเว้น

InvalidOperationException

ทั้ง source และ fileInfo เป็น null หรือ source เป็น null และ fileInfo แสดงถึงไดเรกทอรี

CreateEntry(string, Stream, SevenZipEntrySettings)

สร้างรายการเดียวภายในไฟล์บีบอัด

public SevenZipArchiveEntry CreateEntry(string name, Stream source, SevenZipEntrySettings newEntrySettings = null)

พารามิเตอร์

name string

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

source Stream

สตรีมข้อมูลนำเข้าของรายการ

newEntrySettings SevenZipEntrySettings

การตั้งค่าการบีบอัดและการเข้ารหัสที่ใช้สำหรับรายการ Aspose.Zip.SevenZip.SevenZipArchiveEntry ที่เพิ่ม

ส่งคืน

SevenZipArchiveEntry

อินสแตนซ์รายการ Zip

ตัวอย่าง

สร้างไฟล์บีบอัด 7z ด้วยการบีบอัด LZMA2 และการเข้ารหัสของรายการทั้งหมด

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(string, string, bool, SevenZipEntrySettings)

สร้างรายการเดียวภายในไฟล์บีบอัด

public SevenZipArchiveEntry CreateEntry(string name, string path, bool openImmediately = false, SevenZipEntrySettings newEntrySettings = null)

พารามิเตอร์

name string

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

path string

ชื่อไฟล์ใหม่ที่มีคุณสมบัติครบถ้วน หรือชื่อไฟล์สัมพัทธ์ที่จะบีบอัด

openImmediately bool

เป็นจริงหากเปิดไฟล์ทันที มิฉะนั้นจะเปิดไฟล์เมื่อบันทึกไฟล์บีบอัด

newEntrySettings SevenZipEntrySettings

การตั้งค่าการบีบอัดและการเข้ารหัสที่ใช้สำหรับรายการ Aspose.Zip.SevenZip.SevenZipArchiveEntry ที่เพิ่ม

ส่งคืน

SevenZipArchiveEntry

อินสแตนซ์รายการ Zip

ตัวอย่าง

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

หมายเหตุ

ชื่อรายการถูกตั้งค่าเฉพาะในพารามิเตอร์ name ชื่อไฟล์ที่ให้ในพารามิเตอร์ path ไม่มีผลต่อชื่อรายการ

หากไฟล์ถูกเปิดทันทีด้วยพารามิเตอร์ openImmediately จะถูกบล็อกจนกว่าไฟล์บีบอัดจะถูกบันทึก

ข้อยกเว้น

ArgumentNullException

path เป็น null

SecurityException

ผู้เรียกไม่มีสิทธิ์เข้าถึงที่จำเป็น

ArgumentException

path ว่างเปล่า มีเฉพาะช่องว่าง หรือมีอักขระที่ไม่ถูกต้อง

UnauthorizedAccessException

การเข้าถึงไฟล์ path ถูกปฏิเสธ

PathTooLongException

path ที่ระบุ ชื่อไฟล์ หรือทั้งสองอย่างเกินความยาวสูงสุดที่กำหนดโดยระบบ ตัวอย่างเช่น บนแพลตฟอร์มที่ใช้ Windows เส้นทางต้องมีความยาวน้อยกว่า 248 อักขระ และชื่อไฟล์ต้องมีความยาวน้อยกว่า 260 อักขระ

NotSupportedException

ไฟล์ที่ path มีเครื่องหมายทวิจารณ์ (:) อยู่กลางสตริง

Dispose()

ดำเนินการตามที่กำหนดโดยแอปพลิเคชันที่เกี่ยวข้องกับการปล่อยหรือรีเซ็ตทรัพยากรที่ไม่ได้จัดการ

public void Dispose()

Dispose(bool)

ดำเนินการตามที่กำหนดโดยแอปพลิเคชันที่เกี่ยวข้องกับการปล่อยหรือรีเซ็ตทรัพยากรที่ไม่ได้จัดการ

protected virtual void Dispose(bool disposing)

พารามิเตอร์

disposing bool

ระบุว่าทรัพยากรที่จัดการควรถูกปล่อยหรือไม่

ExtractToDirectory(string, string)

แยกไฟล์ทั้งหมดในไฟล์บีบอัดไปยังไดเรกทอรีที่กำหนด

public void ExtractToDirectory(string destinationDirectory, string password = null)

พารามิเตอร์

destinationDirectory string

เส้นทางไปยังไดเรกทอรีที่จะวางไฟล์ที่แยกออกมา

password string

รหัสผ่านสำหรับการถอดรหัสเนื้อหา (ถ้ามี)

ตัวอย่าง

using (var archive = new SevenZipArchive("archive.7z")) 
{ 
   archive.ExtractToDirectory("C:\extracted");
}

หมายเหตุ

หากไดเรกทอรีไม่อยู่ จะถูกสร้างขึ้น

password จะใช้สำหรับการถอดรหัสเนื้อหาเท่านั้น หากชื่อไฟล์ถูกเข้ารหัสให้ระบุรหัสผ่านใน Aspose.Zip.SevenZip.SevenZipArchive.#ctor(System.String,System.String) หรือ Aspose.Zip.SevenZip.SevenZipArchive.#ctor(System.IO.Stream,System.String) ตัวสร้าง

ข้อยกเว้น

ArgumentNullException

destinationDirectory เป็น null

PathTooLongException

เส้นทางที่ระบุ ชื่อไฟล์ หรือทั้งสองอย่างเกินความยาวสูงสุดที่กำหนดโดยระบบ ตัวอย่างเช่น บนแพลตฟอร์มที่ใช้ Windows เส้นทางต้องมีความยาวน้อยกว่า 248 อักขระ และชื่อไฟล์ต้องมีความยาวน้อยกว่า 260 อักขระ

SecurityException

ผู้เรียกไม่มีสิทธิ์เข้าถึงไดเรกทอรีที่มีอยู่

NotSupportedException

หากไดเรกทอรีไม่อยู่ เส้นทางมีเครื่องหมายทวิจารณ์ (:) ที่ไม่ใช่ส่วนหนึ่งของชื่อไดรฟ์ (“C:")

ArgumentException

destinationDirectory เป็นสตริงที่มีความยาวเป็นศูนย์ มีเฉพาะช่องว่าง หรือมีอักขระที่ไม่ถูกต้องหนึ่งตัวหรือมากกว่า คุณสามารถตรวจสอบอักขระที่ไม่ถูกต้องได้โดยใช้ System.IO.Path.GetInvalidPathChars วิธีการ - หรือ - เส้นทางมีการต่อท้ายด้วยหรือมีเพียงเครื่องหมายทวิจารณ์ (:)

IOException

ไดเรกทอรีที่ระบุโดยเส้นทางเป็นไฟล์ - หรือ - ชื่อเครือข่ายไม่เป็นที่รู้จัก

InvalidDataException

ไฟล์บีบอัดเสียหาย

Save(Stream)

บันทึกไฟล์บีบอัด 7z ไปยังสตรีมที่กำหนด

public void Save(Stream output)

พารามิเตอร์

output Stream

สตรีมปลายทาง

ตัวอย่าง

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

หมายเหตุ

output ต้องสามารถค้นหาได้

ข้อยกเว้น

ArgumentException

output ไม่รองรับการค้นหา

ArgumentNullException

output เป็น null

InvalidOperationException

ตัวเข้ารหัสล้มเหลวในการบีบอัดข้อมูล

Save(string)

บันทึกไฟล์บีบอัดไปยังไฟล์ปลายทางที่กำหนด

public void Save(string destinationFileName)

พารามิเตอร์

destinationFileName string

เส้นทางของไฟล์บีบอัดที่จะสร้าง หากชื่อไฟล์ที่ระบุชี้ไปยังไฟล์ที่มีอยู่ จะถูกเขียนทับ

ตัวอย่าง

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");
   }
}

หมายเหตุ

สามารถบันทึกไฟล์บีบอัดไปยังเส้นทางเดียวกับที่โหลดมา อย่างไรก็ตาม ไม่แนะนำให้ใช้วิธีนี้เนื่องจากวิธีนี้จะใช้การคัดลอกไปยังไฟล์ชั่วคราว

ข้อยกเว้น

ArgumentNullException

destinationFileName เป็น null

SecurityException

ผู้เรียกไม่มีสิทธิ์เข้าถึงที่จำเป็น

ArgumentException

destinationFileName ว่างเปล่า มีเฉพาะช่องว่าง หรือมีอักขระที่ไม่ถูกต้อง

UnauthorizedAccessException

การเข้าถึงไฟล์ destinationFileName ถูกปฏิเสธ

PathTooLongException

destinationFileName ที่ระบุ ชื่อไฟล์ หรือทั้งสองอย่างเกินความยาวสูงสุดที่กำหนดโดยระบบ ตัวอย่างเช่น บนแพลตฟอร์มที่ใช้ Windows เส้นทางต้องมีความยาวน้อยกว่า 248 อักขระ และชื่อไฟล์ต้องมีความยาวน้อยกว่า 260 อักขระ

NotSupportedException

ไฟล์ที่ destinationFileName มีเครื่องหมายทวิจารณ์ (:) อยู่กลางสตริง

SaveSplit(string, SplitSevenZipArchiveSaveOptions)

บันทึกไฟล์บีบอัดหลายเล่มไปยังไดเรกทอรีปลายทางที่กำหนด

public void SaveSplit(string destinationDirectory, SplitSevenZipArchiveSaveOptions options)

พารามิเตอร์

destinationDirectory string

เส้นทางไปยังไดเรกทอรีที่ไฟล์บีบอัดจะถูกสร้างขึ้น

options SplitSevenZipArchiveSaveOptions

ตัวเลือกสำหรับการบันทึกไฟล์บีบอัด รวมถึงชื่อไฟล์

ตัวอย่าง

using (SevenZipArchive archive = new SevenZipArchive())
{
    archive.CreateEntry("entry.bin", "data.bin");
    archive.SaveSplit(@"C:\Folder",  new SplitSevenZipArchiveSaveOptions("volume", 65536));
}

หมายเหตุ

วิธีนี้จะสร้างไฟล์หลายไฟล์ (n) ชื่อไฟล์.7z.001, ชื่อไฟล์.7z.002, ..., ชื่อไฟล์.7z.(n)

ไม่สามารถทำให้ไฟล์บีบอัดที่มีอยู่เป็นหลายเล่มได้

ข้อยกเว้น

InvalidOperationException

ไฟล์บีบอัดนี้ถูกเปิดจากแหล่งที่มีอยู่

ArgumentNullException

destinationDirectory เป็น null

SecurityException

ผู้เรียกไม่มีสิทธิ์เข้าถึงไดเรกทอรีที่จำเป็น

ArgumentException

destinationDirectory มีอักขระที่ไม่ถูกต้อง เช่น “, >, < หรือ |

PathTooLongException

เส้นทางที่ระบุเกินความยาวสูงสุดที่กำหนดโดยระบบ

 แบบไทย