Reputation: 1825
I have LZH archive (.lzh, .lha extensions of archive), and need to extract file from it in .NET Framework 4? Does .NET Framework 4 have some built in toolset for this?
Upvotes: 0
Views: 1414
Reputation: 1
Thanks very much to the author above for the link to LHA Decompressor. I have posted a simple implementation of it for reference.
//Extracts all files in the .lzh archive
LhaFile lhaFile = null;
byte[] dest = new byte[8];
List<string> extractedFileList = new List<string>();
lhaFile = new LhaFile(filePath, Encoding.UTF7);
IEnumerator<LhaEntry> enumerator = lhaFile.GetEnumerator();
while (enumerator.MoveNext())
{
string fileName = enumerator.Current.GetPath();
LhaEntry lhaEntry = lhaFile.GetEntry(fileName);
dest = lhaFile.GetEntryBytes(lhaEntry);
File.WriteAllBytes(Path.Combine(extractionPath, fileName), dest);
string fullPath = Path.Combine(extractionPath, fileName);
extractedFileList.Add(fullPath);
}
lhaFile.Close();
Upvotes: -1