Class ArchiveEntry

Class ArchiveEntry

Tên không gian: Aspose.Zip Tổng hợp: Aspose.Zip.dll (25.5.0)

Hiển thị một tập tin duy nhất trong lưu trữ.

public abstract class ArchiveEntry : IArchiveFileEntry

Inheritance

object ArchiveEntry

Derived

ArchiveEntryEncrypted , ArchiveEntryPlain

Implements

IArchiveFileEntry

Thành viên thừa kế

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

Remarks

Nhập một ví dụ Aspose.Zip.ArchiveEntry vào Aspose.Zip.ArchiveEntryCrypted để xác định xem nhập được mã hóa hay không.

Constructors

ArchiveEntry(Bảng, CompressionSettings, FuncẤn Độ)

Bắt đầu một trường hợp mới của lớp Aspose.Zip.ArchiveEntry.

protected ArchiveEntry(string name, CompressionSettings compressionSettings, Func<stream> sourceProvider, uint fileAttributes)

Parameters

name string

nhập tên

compressionSettings CompressionSettings

Cài đặt để làm trúng hoặc làm trúng.

sourceProvider Func < Stream >

Phương pháp trả về dòng với dữ liệu nhập cũng được nén.

fileAttributes uint

thuộc tính của hệ thống file.

ArchiveEntry(string, CompressionSettings, Stream, uint, FileSystemInfo)

Bắt đầu một trường hợp mới của lớp Aspose.Zip.ArchiveEntry.

protected ArchiveEntry(string name, CompressionSettings compressionSettings, Stream source, uint fileAttributes, FileSystemInfo fileInfo = null)

Parameters

name string

nhập tên

compressionSettings CompressionSettings

Cài đặt để làm trúng hoặc làm trúng.

source Stream

Stream với dữ liệu nhập hoặc để được nén hoặc để được nén.

fileAttributes uint

thuộc tính của hệ thống file.

fileInfo FileSystemInfo

File hoặc directory info entry based on.

Properties

Comment

Nhận bình luận về bài đăng trong hồ sơ.

public string Comment { get; protected set; }

Giá trị bất động sản

string

CompressedSize

Nhận kích thước của tệp bị nén.

public ulong CompressedSize { get; }

Giá trị bất động sản

ulong

CompressionSettings

Có các cài đặt để làm trúng hoặc làm trúng.

public CompressionSettings CompressionSettings { get; }

Giá trị bất động sản

CompressionSettings

DataSource

Nguồn cho nhập nếu nhập được thêm vào lưu trữ, không được rút ra.

public Stream DataSource { get; }

Giá trị bất động sản

Stream

Remarks

Trước khi được phân bổ, nguồn là không. Nguồn này có thể được phân bổ trong phương pháp ‘Archive.Save’ trong một số trường hợp.

FileAttributes

Nhận các thuộc tính tệp từ hệ thống lưu trữ.

protected FileAttributes FileAttributes { get; }

Giá trị bất động sản

FileAttributes

IsDirectory

Nó nhận được một giá trị cho thấy liệu nhập có đại diện cho một thư mục hay không.

public bool IsDirectory { get; }

Giá trị bất động sản

bool

ModificationTime

Nhận hoặc đặt ngày và thời gian được sửa đổi cuối cùng.

public DateTime ModificationTime { get; set; }

Giá trị bất động sản

DateTime

Name

Nhận tên vào trong tài liệu.

public string Name { get; protected set; }

Giá trị bất động sản

string

UncompressedSize

Nhận kích thước của tệp ban đầu.

public ulong UncompressedSize { get; }

Giá trị bất động sản

ulong

Methods

Extract(Thẻ, string)

Xét nhập vào hệ thống tệp theo con đường được cung cấp.

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

Parameters

path string

Đường đến tập tin đích. nếu tập tin đã tồn tại, nó sẽ được viết quá.

password string

Tùy chọn mật khẩu cho decryption

Returns

FileInfo

Thông tin file của file composed.

Examples

Thu thập hai bản ghi zip, mỗi bản ghi có mật khẩu riêng

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

Người gọi không có giấy phép cần thiết để truy cập.

ArgumentException

Đường path’ là trống, chỉ chứa các không gian trắng, hoặc chứa các ký tự vô hiệu.

UnauthorizedAccessException

Truy cập vào tệp path" bị từ chối.

PathTooLongException

Lối đi path", tên tệp, hoặc cả hai vượt quá chiều dài tối đa được xác định bởi hệ thống. Ví dụ, trên nền tảng dựa trên Windows, các con đường phải nhỏ hơn 248 ký tự, và tên tệp phải nhỏ hơn 260 ký tự.

NotSupportedException

Tệp ở path’ chứa một cột (:) ở giữa dòng.

FileNotFoundException

file không được tìm thấy.

DirectoryNotFoundException

Con đường được chỉ định là vô hiệu, chẳng hạn như ở trên một ổ đĩa không được vẽ.

IOException

Tệp đã mở rồi.

InvalidDataException

Dữ liệu bị hư hỏng. -or- CRC hoặc MAC xác minh thất bại cho nhập.

Extract(dòng, string)

Thu thập nhập vào dòng cung cấp.

public void Extract(Stream destination, string password = null)

Parameters

destination Stream

Destination stream. phải được viết.

password string

Tùy chọn mật khẩu cho decryption

Examples

Thu thập một bản ghi zip với mật khẩu.

using (FileStream zipFile = File.Open("archive.zip", FileMode.Open))
{
    using (Archive archive = new Archive(zipFile))
    {
        archive.Entries[0].Extract(httpResponseStream, "p@s$");
    }
}

Exceptions

InvalidDataException

Dữ liệu bị hư hỏng. -or- CRC hoặc MAC xác minh thất bại cho nhập.

IOException

Nguồn gốc bị hư hỏng hoặc không thể đọc được.

ArgumentException

destination’ does not support writing.

Open(String)

Mở đầu vào cho khai thác và cung cấp một dòng với nội dung đầu vào bị hỏng.

public Stream Open(string password = null)

Parameters

password string

Tùy chọn mật khẩu cho decryption

Returns

Stream

dòng mà đại diện cho nội dung của bài đăng.

Examples

Sử dụng :Stream decompressed = entry.Open();

.NET 4.0 và cao hơn - sử dụng phương pháp Stream.CopyTo:decompressed.CopyTo(httpResponse.OutputStream)

.NET 3.5 và trước - sao chép byte bằng tay:

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

Sự kiện Type

EventHandler < ProgressEventArgs >

Examples

archive.Entries[0].CompressionProgressed += (s, e) =&gt; { int percent = (int)((100 * (long)e.ProceededBytes) / entrySourceStream.Length); };

Remarks

Người gửi sự kiện là một trường hợp Aspose.Zip.ArchiveEntry.

ExtractionProgressed

Tăng khi một phần của dòng chảy thô được rút ra.

public event EventHandler<progresseventargs> ExtractionProgressed

Sự kiện Type

EventHandler < ProgressEventArgs >

Examples

archive.Entries[0].ExtractionProgressed += (s, e) =&gt; { int percent = (int)((100 * e.ProceededBytes) / ((ArchiveEntry)s).UncompressedSize); };

Remarks

Người gửi sự kiện là một trường hợp Aspose.Zip.ArchiveEntry.

 Tiếng Việt