Class ArchiveEntry

Class ArchiveEntry

De naam: Aspose.Zip Verzameling: Aspose.Zip.dll (25.5.0)

Representeert een enkele bestand binnen het archief.

public abstract class ArchiveEntry : IArchiveFileEntry

Inheritance

object ArchiveEntry

Derived

ArchiveEntryEncrypted , ArchiveEntryPlain

Implements

IArchiveFileEntry

Geëerbiede leden

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

Remarks

Stel een Aspose.Zip.ArchiveEntry-instantie in naar Aspose.Zip.ArchiveEntry Encrypt om te bepalen of de ingang is versleuteld of niet.

Constructors

ArchiveEntry(String, CompressionSettings, Funcen uint)

Het initiërt een nieuwe instantie van de Aspose.Zip.ArchiveEntry-klasse.

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

Parameters

name string

De ingangnaam.

compressionSettings CompressionSettings

Settings voor compressie of decompressie.

sourceProvider Func < Stream >

De methode om de stroom terug te brengen met inputgegevens moet ook worden gecomprimeerd.

fileAttributes uint

Attributen van het bestandssysteem.

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

Het initiërt een nieuwe instantie van de Aspose.Zip.ArchiveEntry-klasse.

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

Parameters

name string

De ingangnaam.

compressionSettings CompressionSettings

Settings voor compressie of decompressie.

source Stream

Stream met invoergegevens om te worden gecomprimeerd of te worden gecomprimeerd.

fileAttributes uint

Attributen van het bestandssysteem.

fileInfo FileSystemInfo

File of directory info de ingang gebaseerd op.

Properties

Comment

Geeft een commentaar van de ingang binnen het archief.

public string Comment { get; protected set; }

Eigendomswaarde

string

CompressedSize

Het krijgt de grootte van de gecomprimeerde bestand.

public ulong CompressedSize { get; }

Eigendomswaarde

ulong

CompressionSettings

Geeft instellingen voor compressie of decompressie.

public CompressionSettings CompressionSettings { get; }

Eigendomswaarde

CompressionSettings

DataSource

Bron voor de invoer als de ingang is toegevoegd aan het archief, niet geëxtraheerd.

public Stream DataSource { get; }

Eigendomswaarde

Stream

Remarks

Deze bron kan worden toegewezen binnen de ‘Archive.Save’ methode in sommige gevallen.

FileAttributes

Het ontvangt bestandsattributen van het hostsysteem.

protected FileAttributes FileAttributes { get; }

Eigendomswaarde

FileAttributes

IsDirectory

Geeft een waarde die aangeeft of de ingang een directory vertegenwoordigt.

public bool IsDirectory { get; }

Eigendomswaarde

bool

ModificationTime

Geeft of stelt de laatste gewijzigde datum en tijd.

public DateTime ModificationTime { get; set; }

Eigendomswaarde

DateTime

Name

Neem de naam van de ingang binnen het archief.

public string Name { get; protected set; }

Eigendomswaarde

string

UncompressedSize

Geeft de grootte van de originele bestand.

public ulong UncompressedSize { get; }

Eigendomswaarde

ulong

Methods

Extract(String en String)

Extract de ingang naar het bestandsysteem door de geleverde route.

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

Parameters

path string

De route naar bestand bestemming.Als het bestand al bestaat, zal het worden overgeschreven.

password string

Optionele wachtwoord voor decryptie.

Returns

FileInfo

De bestandinformatie van de gecombineerde bestand.

Examples

Extraeer twee inzichten uit zip archief, elk met eigen wachtwoord

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

De oproepgever heeft niet de vereiste toestemming om toegang te krijgen.

ArgumentException

De path’ is leeg, bevat alleen witte ruimtes of bevat invalide tekens.

UnauthorizedAccessException

De toegang tot het bestand path’ wordt geweigerd.

PathTooLongException

De aangegeven path’, bestandsnaam, of beide overschrijden de door het systeem gedefinieerde maximale lengte. Bijvoorbeeld, op Windows-gebaseerde platforms, moeten paden minder dan 248 tekens zijn, en bestandsnamen moeten minder dan 260 tekens zijn.

NotSupportedException

Het bestand op path’ bevat een kolom (:) in het midden van de string.

FileNotFoundException

Het bestand is niet gevonden.

DirectoryNotFoundException

De aangegeven route is ongeldig, bijvoorbeeld op een onmapped drive.

IOException

Het bestand is al open.

InvalidDataException

Data is corrupt. -or- CRC of MAC verificatie mislukt voor de ingang.

Extract(Strom, Strom)

Extract de ingang naar de aangeboden stroom.

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

Parameters

destination Stream

Destination stream. moet geschreven zijn.

password string

Optionele wachtwoord voor decryptie.

Examples

Verwijder een zip archief met een wachtwoord.

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 of MAC verificatie mislukt voor de ingang.

IOException

De bron is corrupt of niet leesbaar.

ArgumentException

destination’ does not support writing.

Open(String)

Open de ingang voor extractie en levert een stroom met gedecomprimeerde inganginhoud.

public Stream Open(string password = null)

Parameters

password string

Optionele wachtwoord voor decryptie.

Returns

Stream

De stroom die de inhoud van de ingang vertegenwoordigt.

Examples

Gebruik :Stream decompressed = entry.Open();

.NET 4.0 en hoger - gebruik Stream.CopyTo methode:decompressed.CopyTo(httpResponse.OutputStream)

.NET 3.5 en eerder - kopieer de byten handmatig:

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

Event type

EventHandler < ProgressEventArgs >

Examples

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

Remarks

Event sender is een Aspose.Zip.ArchiveEntry instantie.

ExtractionProgressed

Verhoogt wanneer een portie grondstrom wordt geëxtracteerd.

public event EventHandler<progresseventargs> ExtractionProgressed

Event type

EventHandler < ProgressEventArgs >

Examples

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

Remarks

Event sender is een Aspose.Zip.ArchiveEntry instantie.

 Nederlands