Class ArchiveEntry

Class ArchiveEntry

ชื่อพื้นที่: Aspose.Zip การประกอบ: Aspose.Zip.dll (25.5.0)

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

public abstract class ArchiveEntry : IArchiveFileEntry

Inheritance

object ArchiveEntry

Derived

ArchiveEntryEncrypted , ArchiveEntryPlain

Implements

IArchiveFileEntry

อนุญาโตตุลาการ

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

คุณสมบัติมูลค่า

string

CompressedSize

ได้รับขนาดของไฟล์ที่บีบอัด

public ulong CompressedSize { get; }

คุณสมบัติมูลค่า

ulong

CompressionSettings

ได้รับการตั้งค่าสําหรับการบีบอัดหรือการบีบอัด

public CompressionSettings CompressionSettings { get; }

คุณสมบัติมูลค่า

CompressionSettings

DataSource

แหล่งกําเนิดสําหรับรายการถ้ารายการจะถูกเพิ่มไปยังเอกสารและไม่ได้รับการสกัด

public Stream DataSource { get; }

คุณสมบัติมูลค่า

Stream

Remarks

ก่อนที่จะกําหนดแหล่งที่มาเป็น null ในบางกรณีแหล่งนี้สามารถกําหนดไว้ภายในวิธีการ ‘Archive.Save’

FileAttributes

รับคุณสมบัติไฟล์จากระบบโฮสต์

protected FileAttributes FileAttributes { get; }

คุณสมบัติมูลค่า

FileAttributes

IsDirectory

ได้รับค่าแสดงให้เห็นว่าการเข้าสู่ระบบเป็นรายชื่อ

public bool IsDirectory { get; }

คุณสมบัติมูลค่า

bool

ModificationTime

รับหรือตั้งค่าวันที่และเวลาที่เปลี่ยนแปลงล่าสุด

public DateTime ModificationTime { get; set; }

คุณสมบัติมูลค่า

DateTime

Name

รับชื่อของรายการภายในเอกสาร

public string Name { get; protected set; }

คุณสมบัติมูลค่า

string

UncompressedSize

ได้รับขนาดของไฟล์เดิม

public ulong UncompressedSize { get; }

คุณสมบัติมูลค่า

ulong

Methods

Extract(รั้ว, รั้ว)

นําเข้าสู่ระบบไฟล์โดยเส้นทางที่ให้

public FileInfo Extract(string path, string password = null)

Parameters

path string

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

password string

ตัวเลือกรหัสผ่านสําหรับการ decryption

Returns

FileInfo

ข้อมูลไฟล์ของไฟล์ประกอบ

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

ArgumentNullException

path’ is null.

SecurityException

ผู้โทรไม่ได้รับอนุญาตให้เข้าถึง

ArgumentException

path" เป็นที่ว่างเปล่ามีพื้นที่สีขาวเท่านั้นหรือมีตัวอักษรที่ไม่ถูกต้อง

UnauthorizedAccessException

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

PathTooLongException

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

NotSupportedException

ไฟล์ใน path" มีคอลัมน์ (:) ในส่วนกลางของเส้น

FileNotFoundException

ไฟล์ไม่ได้พบ

DirectoryNotFoundException

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

IOException

ไฟล์นี้เปิดแล้ว

InvalidDataException

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

InvalidDataException

Data is corrupt. -or- การตรวจสอบ CRC หรือ MAC ไม่สามารถเข้าสู่ระบบได้

IOException

แหล่งที่รบกวนหรือไม่สามารถอ่านได้

ArgumentException

destination’ does not support writing.

Open(รั้ว)

เปิดป้อนสําหรับการสกัดและให้การไหลที่มีเนื้อหาป้อนที่ถูกบีบอัด

public Stream Open(string password = null)

Parameters

password string

ตัวเลือกรหัสผ่านสําหรับการ decryption

Returns

Stream

กระแสที่แสดงให้เห็นถึงเนื้อหาของป้อน

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 &lt; (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) =&gt; { 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) =&gt; { int percent = (int)((100 * e.ProceededBytes) / ((ArchiveEntry)s).UncompressedSize); };

Remarks

ผู้ส่งเหตุการณ์เป็นตัวอย่าง Aspose.Zip.ArchiveEntry

 แบบไทย