Class SevenZipArchiveEntry

Class SevenZipArchiveEntry

Namn på plats: Aspose.Zip.SevenZip Sammanfattning: Aspose.Zip.dll (25.5.0)

Representerar en enda fil inom 7z-arkiv.

public abstract class SevenZipArchiveEntry : IArchiveFileEntry

Inheritance

object SevenZipArchiveEntry

Derived

SevenZipArchiveEntryEncrypted , SevenZipArchiveEntryPlain

Implements

IArchiveFileEntry

Arvsmedlemmar

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

Remarks

Ange en Aspose.Zip.SevenZip.SevenZipArchiveEntry instans till Aspose.Zip.SevenZip.SevenZipArchiveEntryKrypterad för att avgöra om inmatningen är krypterad eller inte.

Properties

CompressedSize

Få storleken på en komprimerad fil.

public ulong CompressedSize { get; }

Fastighetsvärde

ulong

CompressionSettings

Få inställningar för kompression eller dekompression.

public SevenZipCompressionSettings CompressionSettings { get; }

Fastighetsvärde

SevenZipCompressionSettings

FileAttributes

Få filattribut från ett värdsystem.

protected FileAttributes FileAttributes { get; }

Fastighetsvärde

FileAttributes

IsDirectory

Det får ett värde som anger om entréen representerar en katalog.

public bool IsDirectory { get; }

Fastighetsvärde

bool

ModificationTime

Det får senast ändrade datum och tid.

public DateTime ModificationTime { get; }

Fastighetsvärde

DateTime

Name

Få namn på ingången inom arkivet.

public string Name { get; protected set; }

Fastighetsvärde

string

Source

Få datakällan ström för ingången.

protected Stream Source { get; }

Fastighetsvärde

Stream

UncompressedSize

Få storleken på en originalfil.

public ulong UncompressedSize { get; }

Fastighetsvärde

ulong

Methods

Extract(String och String)

Extraherar ingången till filsystemet genom den föreslagna vägen.

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

Parameters

path string

Vägen till målfilen. om filen redan existerar, kommer den att översättas.

password string

Alternativt lösenord för dekryptering.

Returns

FileInfo

Information om filen av en kompositfil.

Examples

using (var archive = new SevenZipArchive("archive.7z"))
{
    archive.Entries[0].Extract("data.bin");
}

Exceptions

ArgumentNullException

path’ is null.

SecurityException

Sökanden har inte behörig tillstånd att komma åt.

ArgumentException

path’ är tom, innehåller endast vita utrymmen, eller innehåller olagliga tecken.

UnauthorizedAccessException

Tillgång till filen path" vägras.

PathTooLongException

Den angivna path’, filnamn, eller båda överstiger den systemdefinierade maximala längden. Till exempel på Windows-baserade plattformar måste vägar vara mindre än 248 tecken, och filnamn måste vara mindre än 260 tecken.

NotSupportedException

Filen på path’ innehåller en kolumn (:) i mitten av raden.

InvalidDataException

Arkivet är korrupt.

Extract(Ström, ström)

Extraherar ingången till den tillhandahållna strömmen.

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

Parameters

destination Stream

Destination stream. måste vara skribar.

password string

Alternativt lösenord för dekryptering.

Examples

Extract en inmatning av zip arkiv med lösenord.

using (var archive = new SevenZipArchive("archive.7z"))
{
    archive.Entries[0].Extract(httpResponseStream);
}

Exceptions

ArgumentException

destination’ does not support writing.

InvalidOperationException

Arkivet är inte öppet för utvinning. - eller - Detta inlägg är en katalog.

InvalidDataException

felaktiga uppgifter inom ingången.

FinalizeCompressedData(Ström, byte[])

Skriv till output stream alla rubriker som följer komprimerade data.

protected abstract int FinalizeCompressedData(Stream outputStream, byte[] encoderProperties)

Parameters

outputStream Stream

Utgångström för ingången.

encoderProperties byte [ ]

egenskaper hos kompressorn.

Returns

int

Antalet “tekniska” byter som läggs till efter inträde betydande data block.

GetDestinationStream(Stream)

Destinationström för ingången, kan dekoreras.

protected abstract Stream GetDestinationStream(Stream outputStream)

Parameters

outputStream Stream

Utgångström för ingången.

Returns

Stream

Destinationsström för ingångskompression.

Open(Sträng)

Öppnar entréen för utvinning och ger en ström med entréinnehåll.

public Stream Open(string password = null)

Parameters

password string

Alternativt lösenord för dekryptering.

Returns

Stream

Strömmen som representerar innehållet i ingången.

Examples

Användning :Stream decompressed = entry.Open();

.NET 4.0 och högre - använd Stream.CopyTo metod:decompressed.CopyTo(httpResponse.OutputStream)

.NET 3.5 och tidigare - kopiera byter manuellt:

byte[] buffer = new byte[8192];
int bytesRead;
while (0 < (bytesRead = decompressed.Read(buffer, 0, buffer.Length)))
 fileStream.Write(buffer, 0, bytesRead);
```</p>

#### Remarks

Read from the stream to get the original content of a file. See examples section.

#### Exceptions

 [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception)

The archive is not opened for extraction. - or - This entry is a directory.

 [InvalidDataException](https://learn.microsoft.com/dotnet/api/system.io.invaliddataexception)

Wrong data within the entry.

### <a id="Aspose_Zip_SevenZip_SevenZipArchiveEntry_CompressionProgressed"></a> CompressionProgressed

Raises when a portion of raw stream compressed.

```csharp
public event EventHandler<progresseventargs> CompressionProgressed

Event typ

EventHandler ochlt; ProgressEventArgs >

Examples

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

Remarks

Event sender är en Aspose.Zip.SevenZip.SevenZipArchiveEntry instans.

Inbjuder inte i multithreaded-läge för LZMA2-inmatningar.

 Svenska