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.SharArchive ที่เตรียมพร้อมสําหรับการบีบอัด
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(DirectoryInfo, บอล)
เพิ่มไฟล์และไดเรกทอรีทั้งหมดในไดเรกทอรี
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.
ผู้โทรไม่ได้รับอนุญาตที่จําเป็นในการเข้าถึง directory”.
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
หลักสูตรการเข้าถึง
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(string, string, บอล)
สร้างรายการเดียวภายในเอกสาร
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" ถูกปฏิเสธ
ระบุ sourcePath’, ชื่อไฟล์, หรือทั้งสองเกินความยาวสูงสุดที่กําหนดโดยระบบ ตัวอย่างเช่นบนแพลตฟอร์มที่ใช้ Windows, เส้นทางต้องมีน้อยกว่า 248 หมายเลขและชื่อไฟล์ต้องมีน้อยกว่า 260 หมายเลข - หรือ -
name’ เป็นยาวเกินไปสําหรับ shar
ไฟล์ที่ 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
นี่คือวิธีที่คุณสามารถลบรายการทั้งหมดยกเว้นครั้งสุดท้าย:
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(int)
ลบป้อนจากรายการป้อนโดย index
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’ เป็น invalid, (เช่นมันอยู่ในไดรฟ์ที่ไม่ได้วาด)
ข้อผิดพลาด 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.