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مشفى لتحديد ما إذا كان الإدخال مشفرًا أم لا.

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 &lt؛ Stream >

طريقة إرجاع التدفق مع بيانات الإدخال إما للضغط.

fileAttributes uint

خصائص من نظام الملفات.

ArchiveEntry(شريط, 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

قبل تخصيص، المصدر صفر.يمكن تخصيص هذا المصدر ضمن طريقة “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

كلمة المرور الاختيارية للتشفير.

Returns

FileInfo

معلومات الملف من الملف المكون.

Examples

استخراج اثنين من الإدخالات من أرشيف zip، كل واحد مع كلمة المرور الخاصة

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

الطريق " فارغ ، يحتوي على مساحات بيضاء فقط ، أو يحتوي على أحرف غير صحيحة.

UnauthorizedAccessException

يتم رفض الوصول إلى ملف path".

PathTooLongException

على سبيل المثال ، على المنصات المستندة إلى Windows ، يجب أن تكون المسارات أقل من 248 حرفًا ، ويجب أن يكون اسم الملف أقل من 260 حرفًا.

NotSupportedException

ملف في path’ يحتوي على عمود (:) في وسط السلسلة.

FileNotFoundException

لم يتم العثور على الملف.

DirectoryNotFoundException

المسار المحدد غير صالح ، على سبيل المثال ، على محرك أقراص غير مسجلة.

IOException

الملف مفتوح بالفعل.

InvalidDataException

يتم تدمير البيانات. -أو- فشل التحقق من CRC أو MAC للدخول.

Extract(الشبكة، string)

إخراج الدخول إلى التدفق المقدم.

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

Parameters

destination Stream

كلمات مفتاحية يجب أن تكون مكتوبة

password string

كلمة المرور الاختيارية للتشفير.

Examples

استخراج إدخال من أرشيف zip مع كلمة المرور.

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

Exceptions

InvalidDataException

يتم تدمير البيانات. -أو- فشل التحقق من CRC أو MAC للدخول.

IOException

المصدر فاسد أو غير قابل للقراءة.

ArgumentException

destination’ does not support writing.

Open(الستار)

يفتح إدخال الاستخراج ويقدم تدفقًا مع محتوى الإدخال المضغوط.

public Stream Open(string password = null)

Parameters

password string

كلمة المرور الاختيارية للتشفير.

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 &lt؛ 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 &lt؛ ProgressEventArgs >

Examples

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

Remarks

إرسال الحدث هو حالة Aspose.Zip.ArchiveEntry.

 عربي