Class ArchiveEntry
ชื่อพื้นที่: Aspose.Zip การประกอบ: Aspose.Zip.dll (25.5.0)
แสดงไฟล์เดียวภายในเอกสาร
public abstract class ArchiveEntry : IArchiveFileEntry
Inheritance
Derived
ArchiveEntryEncrypted , ArchiveEntryPlain
Implements
อนุญาโตตุลาการ
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Remarks
เลือกตัวอย่าง Aspose.Zip.ArchiveEntry ไปยัง Aspose.Zip.ArchiveEntry Encrypted เพื่อระบุว่าการเข้าสู่ระบบถูกเข้ารหัสหรือไม่
Constructors
ArchiveEntry(ลวด, CompressionSettings, Funcภาษาไทย)
เริ่มต้นตัวอย่างใหม่ของคลาส Aspose.Zip.ArchiveEntry
protected ArchiveEntry(string name, CompressionSettings compressionSettings, Func<stream> sourceProvider, uint fileAttributes)
Parameters
name
string
ชื่อเข้า
compressionSettings
CompressionSettings
การตั้งค่าสําหรับการบีบอัดหรือบีบอัด
sourceProvider
Func
<
Stream
>
วิธีการส่งกลับกับข้อมูลการเข้าทั้งจะถูกบีบอัด
fileAttributes
uint
คุณสมบัติจากระบบไฟล์
ArchiveEntry(string, CompressionSettings, Stream, uint, FileSystemInfo)
เริ่มต้นตัวอย่างใหม่ของคลาส Aspose.Zip.ArchiveEntry
protected ArchiveEntry(string name, CompressionSettings compressionSettings, Stream source, uint fileAttributes, FileSystemInfo fileInfo = null)
Parameters
name
string
ชื่อเข้า
compressionSettings
CompressionSettings
การตั้งค่าสําหรับการบีบอัดหรือบีบอัด
source
Stream
การไหลที่มีข้อมูลการเข้าทั้งจะถูกบีบอัดหรือจะถูกบีบอัด
fileAttributes
uint
คุณสมบัติจากระบบไฟล์
fileInfo
FileSystemInfo
ไฟล์หรือไดเรกทอรีข้อมูลการเข้าสู่ระบบตาม
Properties
Comment
ได้รับความคิดเห็นเกี่ยวกับการเข้าสู่ระบบภายในเอกสาร
public string Comment { get; protected set; }
คุณสมบัติมูลค่า
CompressedSize
ได้รับขนาดของไฟล์ที่บีบอัด
public ulong CompressedSize { get; }
คุณสมบัติมูลค่า
CompressionSettings
ได้รับการตั้งค่าสําหรับการบีบอัดหรือการบีบอัด
public CompressionSettings CompressionSettings { get; }
คุณสมบัติมูลค่า
DataSource
แหล่งกําเนิดสําหรับรายการถ้ารายการจะถูกเพิ่มไปยังเอกสารและไม่ได้รับการสกัด
public Stream DataSource { get; }
คุณสมบัติมูลค่า
Remarks
ก่อนที่จะกําหนดแหล่งที่มาเป็น null ในบางกรณีแหล่งนี้สามารถกําหนดไว้ภายในวิธีการ ‘Archive.Save’
FileAttributes
รับคุณสมบัติไฟล์จากระบบโฮสต์
protected FileAttributes FileAttributes { get; }
คุณสมบัติมูลค่า
IsDirectory
ได้รับค่าแสดงให้เห็นว่าการเข้าสู่ระบบเป็นรายชื่อ
public bool IsDirectory { get; }
คุณสมบัติมูลค่า
ModificationTime
รับหรือตั้งค่าวันที่และเวลาที่เปลี่ยนแปลงล่าสุด
public DateTime ModificationTime { get; set; }
คุณสมบัติมูลค่า
Name
รับชื่อของรายการภายในเอกสาร
public string Name { get; protected set; }
คุณสมบัติมูลค่า
UncompressedSize
ได้รับขนาดของไฟล์เดิม
public ulong UncompressedSize { get; }
คุณสมบัติมูลค่า
Methods
Extract(รั้ว, รั้ว)
นําเข้าสู่ระบบไฟล์โดยเส้นทางที่ให้
public FileInfo Extract(string path, string password = null)
Parameters
path
string
เส้นทางไปยังไฟล์เป้าหมาย หากไฟล์มีอยู่แล้วมันจะถูกเขียนเกินไป
password
string
ตัวเลือกรหัสผ่านสําหรับการ decryption
Returns
ข้อมูลไฟล์ของไฟล์ประกอบ
Examples
extract 2 entries of zip archive, แต่ละด้วยรหัสผ่านของตัวเอง
using (FileStream zipFile = File.Open("archive.zip", FileMode.Open))
{
using (Archive archive = new Archive(zipFile))
{
archive.Entries[0].Extract("first.bin", "first_pass");
archive.Entries[1].Extract("second.bin", "second_pass");
}
}
Exceptions
path’ is null.
ผู้โทรไม่ได้รับอนุญาตให้เข้าถึง
path" เป็นที่ว่างเปล่ามีพื้นที่สีขาวเท่านั้นหรือมีตัวอักษรที่ไม่ถูกต้อง
การเข้าถึงไฟล์ path" ถูกปฏิเสธ
ระบุ path’, ชื่อไฟล์, หรือทั้งสองเกินความยาวสูงสุดที่กําหนดโดยระบบ ตัวอย่างเช่นบนแพลตฟอร์มที่ใช้ Windows, เส้นทางจะต้องน้อยกว่า 248 หมายเลขและชื่อไฟล์จะต้องน้อยกว่า 260 หมายเลข
ไฟล์ใน path" มีคอลัมน์ (:) ในส่วนกลางของเส้น
ไฟล์ไม่ได้พบ
เส้นทางที่ระบุไม่ถูกต้องเช่นอยู่บนไดรฟ์ที่ไม่มีแผนที่
ไฟล์นี้เปิดแล้ว
Data is corrupt. -or- การตรวจสอบ CRC หรือ MAC ไม่สามารถเข้าสู่ระบบได้
Extract(กระแส, string)
นําเข้าสู่การไหลที่ให้
public void Extract(Stream destination, string password = null)
Parameters
destination
Stream
จุดหมายปลายทาง Stream. ต้องการเขียนได้
password
string
ตัวเลือกรหัสผ่านสําหรับการ decryption
Examples
extract a entry of zip archive ด้วยรหัสผ่าน
using (FileStream zipFile = File.Open("archive.zip", FileMode.Open))
{
using (Archive archive = new Archive(zipFile))
{
archive.Entries[0].Extract(httpResponseStream, "p@s$");
}
}
Exceptions
Data is corrupt. -or- การตรวจสอบ CRC หรือ MAC ไม่สามารถเข้าสู่ระบบได้
แหล่งที่รบกวนหรือไม่สามารถอ่านได้
destination’ does not support writing.
Open(รั้ว)
เปิดป้อนสําหรับการสกัดและให้การไหลที่มีเนื้อหาป้อนที่ถูกบีบอัด
public Stream Open(string password = null)
Parameters
password
string
ตัวเลือกรหัสผ่านสําหรับการ decryption
Returns
กระแสที่แสดงให้เห็นถึงเนื้อหาของป้อน
Examples
การใช้งาน :Stream decompressed = entry.Open();
.NET 4.0 และสูงกว่า - ใช้วิธีการ Stream.CopyTo:decompressed.CopyTo(httpResponse.OutputStream)
.NET 3.5 และก่อนหน้านี้ - คัดลอกไบต์ด้วยตนเอง:
byte[] buffer = new byte[8192];
int bytesRead;
while (0 < (bytesRead = decompressed.Read(buffer, 0, buffer.Length)))
fileStream.Write(buffer, 0, bytesRead);
```</p>
#### Remarks
<p>Read from the stream to get the original content of a file. See examples section.</p>
#### Exceptions
[InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception)
The archive is in an incorrect state.
### <a id="Aspose_Zip_ArchiveEntry_CompressionProgressed"></a> CompressionProgressed
Raises when a portion of raw stream compressed.
```csharp
public event EventHandler<progresseventargs> CompressionProgressed
ประเภทเหตุการณ์
EventHandler < ProgressEventArgs >
Examples
archive.Entries[0].CompressionProgressed += (s, e) => { int percent = (int)((100 * (long)e.ProceededBytes) / entrySourceStream.Length); };
Remarks
ผู้ส่งเหตุการณ์เป็นตัวอย่าง Aspose.Zip.ArchiveEntry
ExtractionProgressed
เพิ่มขึ้นเมื่อส่วนหนึ่งของกระแสวัตถุดิบสกัด
public event EventHandler<progresseventargs> ExtractionProgressed
ประเภทเหตุการณ์
EventHandler < ProgressEventArgs >
Examples
archive.Entries[0].ExtractionProgressed += (s, e) => { int percent = (int)((100 * e.ProceededBytes) / ((ArchiveEntry)s).UncompressedSize); };
Remarks
ผู้ส่งเหตุการณ์เป็นตัวอย่าง Aspose.Zip.ArchiveEntry