Class LhaArchive

Class LhaArchive

Namespace: Aspose.Zip.Lha
Assembly: Aspose.Zip.dll (25.2.0)

This class represents LHA (.lzh) archive file.

public class LhaArchive : IArchive, IDisposable

Inheritance

objectLhaArchive

Implements

IArchive, IDisposable

Inherited Members

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

Remarks

Only following compression methods are supported:

MethodExplanation
lh0Uncompressed
lh48 KiB sliding dictionary and static Huffman
lh516 KiB sliding dictionary and static Huffman
lh664 KiB sliding dictionary and static Huffman
lh7128 KiB sliding dictionary and static Huffman
lhx1 Mib sliding dictionary and static Huffman
lhdDirectory

Constructors

LhaArchive(Stream)

Initializes a new instance of the Aspose.Zip.Lha.LhaArchive class and composes entries list can be extracted from the archive.

public LhaArchive(Stream sourceStream)

Parameters

sourceStream Stream

The source of the archive.

Remarks

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

Exceptions

ArgumentNullException

sourceStream is null

ArgumentException

sourceStream is unseekable.

InvalidDataException

Inappropriate data found.

LhaArchive(string)

Initializes a new instance of the Aspose.Zip.Lha.LhaArchive class and composes entries list can be extracted from the archive.

public LhaArchive(string path)

Parameters

path string

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

Examples

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

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

Remarks

This constructor does not decompress any entry. See Aspose.Zip.ArchiveEntry.Open(System.String) 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

File is corrupted.

Properties

Entries

Gets file entries of Aspose.Zip.Lha.LhaArchiveEntry type constituting the archive.

public ReadOnlyCollection<lhaarchiveentry> Entries { get; }

Property Value

ReadOnlyCollection<LhaArchiveEntry&gt;

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 LhaArchive("archive.lzh")) 
{ 
   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 existing directory.

NotSupportedException

If directory does not exist, 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.

InvalidDataException

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

 English