Class RarArchiveEntry

Class RarArchiveEntry

Tên không gian: Aspose.Zip.Rar 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 RarArchiveEntry : IArchiveFileEntry

Inheritance

object RarArchiveEntry

Derived

RarArchiveEntryEncrypted , RarArchiveEntryPlain

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.Rar.RarArchiveEntry vào Aspose.Zip.Rar.RarArchiveEntryCrypted để xác định xem nhập được mã hóa hay không.

Properties

CompressedSize

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

public ulong CompressedSize { get; }

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

ulong

CreationTime

Nhận được ngày và thời gian sáng tạo.

public DateTime CreationTime { get; }

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

DateTime

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

LastAccessTime

Nhận ngày và thời gian truy cập cuối cùng.

public DateTime LastAccessTime { get; }

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

DateTime

ModificationTime

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

public DateTime ModificationTime { get; }

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

DateTime

Name

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

public string Name { get; }

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

string

Source

Nhận dòng nguồn dữ liệu cho việc nhập.

protected Stream Source { get; set; }

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

Stream

UncompressedSize

Nhận kích thước của một tập tin 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

Tiết xuất hai bài đăng từ RAR ARCHIVE.

using (FileStream rarFile = File.Open("archive.rar", FileMode.Open))
{
    using (RarArchive archive = new RarArchive(rarFile))
    {
        archive.Entries[0].Extract("first.bin", "pass");
        archive.Entries[1].Extract("second.bin", "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

Tiết xuất một bản ghi của các tài liệu hiếm với mật khẩu.

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

Exceptions

InvalidDataException

CRC hoặc MAC xác minh thất bại cho việc nhập.

ArgumentException

destination’ does not support writing.

InvalidDataException

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

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. Nó cũng có thể được đặt trong Aspose.Zip.Rar.RarArchiveLoadOptions.DecryptionPassword.

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 < (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>

### <a id="Aspose_Zip_Rar_RarArchiveEntry_ExtractionProgressed"></a> ExtractionProgressed

Raises when a portion of raw stream extracted.

```csharp
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) / ((RarArchiveEntry)s).UncompressedSize); };

Remarks

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

 Tiếng Việt