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
Implements
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:
Method | Explanation |
---|---|
lh0 | Uncompressed |
lh4 | 8 KiB sliding dictionary and static Huffman |
lh5 | 16 KiB sliding dictionary and static Huffman |
lh6 | 64 KiB sliding dictionary and static Huffman |
lh7 | 128 KiB sliding dictionary and static Huffman |
lhx | 1 Mib sliding dictionary and static Huffman |
lhd | Directory |
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
sourceStream
is null
sourceStream
is unseekable.
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
path
is null.
The caller does not have the required permission to access.
The path
is empty, contains only white spaces, or contains invalid characters.
Access to file path
is denied.
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.
File at path
contains a colon (:) in the middle of the string.
The file is not found.
The specified path is invalid, such as being on an unmapped drive.
The file is already open.
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>
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
destinationDirectory
is null.
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.
The caller does not have the required permission to access existing directory.
If directory does not exist, path contains a colon character (:) that is not part of a drive label (“C:").
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 (:).
The directory specified by path is a file. -or- The network name is not known.
Wrong password has been supplied. - or - Archive is corrupted.