Class LzxArchive

Class LzxArchive

Namespace: Aspose.Zip.Lzx
Assembly: Aspose.Zip.dll (25.12.0)

This class represents a LZX (.lzx) archive file.

public class LzxArchive : IArchive, IDisposable

Inheritance

object LzxArchive

Implements

IArchive , IDisposable

Inherited Members

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

Constructors

LzxArchive(Stream, LzxLoadOptions)

Initializes a new instance of the Aspose.Zip.Lzx.LzxArchive class and composes an entry list can be extracted from the archive.

public LzxArchive(Stream extractionSource, LzxLoadOptions loadOptions = null)

Parameters

extractionSource Stream

The source of the archive.

loadOptions LzxLoadOptions

Options to load existing archive with.

Remarks

This constructor does not decompress any entry. See Aspose.Zip.Lzx.LzxArchiveEntry.Extract(System.IO.Stream) method for decompressing.

Exceptions

ArgumentNullException

extractionSource is null.

ArgumentException

extractionSource does not support seeking.

InvalidDataException

Wrong signature for archive. - or - The file is not a LZX archive.

NotImplementedException

Lzx archive contains merged entries.

EndOfStreamException

The extractionSource stream is too short.

LzxArchive(string, LzxLoadOptions)

Initializes a new instance of the Aspose.Zip.Lzx.LzxArchive class and composes an entry list can be extracted from the archive.

public LzxArchive(string path, LzxLoadOptions loadOptions = null)

Parameters

path string

The fully qualified or the relative path to the archive file.

loadOptions LzxLoadOptions

Options to load existing archive with.

Examples

The following example extracts an archive, then decompress first entry to a MemoryStream.

var extracted = new MemoryStream();
using (LzxArchive archive = new LzxArchive("sample.lzx"))
{
    archive.Entries[0].Extract(extracted);
}

Remarks

This constructor does not decompress any entry. See Aspose.Zip.Lzx.LzxArchiveEntry.Extract(System.IO.Stream) method for decompressing.

Exceptions

ArgumentNullException

path is null.

SecurityException

The caller does not have the required permission to access.

ArgumentException

The path is empty, contains only white spaces, or contains invalid characters.

UnauthorizedAccessException

Access to file path is denied.

PathTooLongException

The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.

NotSupportedException

File at path contains a colon (:) in the middle of the string.

FileNotFoundException

The file is not found.

DirectoryNotFoundException

The specified path is invalid, such as being on an unmapped drive.

IOException

The file is already open.

InvalidDataException

The file is corrupted.

NotImplementedException

Lzx archive contains merged entries.

EndOfStreamException

The file is too short.

Properties

Entries

Gets file entries of Aspose.Zip.Lzx.LzxArchiveEntry type constituting the archive.

public ReadOnlyCollection<LzxArchiveEntry> Entries { get; }

Property Value

ReadOnlyCollection < LzxArchiveEntry >

Methods

Dispose()

public void Dispose()

ExtractToDirectory(string)

Extracts all the files and directories in the archive to the directory provided.

public void ExtractToDirectory(string destinationDirectory)

Parameters

destinationDirectory string

The path to the directory to place the extracted files in.

Examples

using (var archive = new LzxArchive("archive.lzx")) 
{ 
   archive.ExtractToDirectory("C:\extracted");
}

Remarks

If the directory does not exist, it will be created.

Exceptions

ArgumentNullException

destinationDirectory is null.

PathTooLongException

The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.

SecurityException

The caller does not have the required permission to access the existing directory.

NotSupportedException

If the directory does not exist, the path contains a colon character (:) that is not part of a drive label (“C:").

ArgumentException

destinationDirectory is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the System.IO.Path.GetInvalidPathChars method. -or- path is prefixed with, or contains, only a colon character (:).

IOException

The directory specified by path is a file. -or- The network name is not known.

ObjectDisposedException

Archive has been disposed and cannot be used.

InvalidDataException

Wrong password has been supplied. - or - Archive is corrupted.

NotSupportedException

Invalid compression method.

OperationCanceledException

In .NET Framework 4.0 and above: Thrown when the extraction is canceled via the provided cancellation token.