【发布时间】:2015-12-13 00:36:33
【问题描述】:
我有 LZH 存档(存档的.lzh、.lha 扩展名),并且需要在 .NET Framework 4 中从中提取文件? .NET Framework 4 是否为此提供了一些内置工具集?
【问题讨论】:
-
It appears 您需要安装日语 Windows 区域设置才能获得对此的本机支持。
我有 LZH 存档(存档的.lzh、.lha 扩展名),并且需要在 .NET Framework 4 中从中提取文件? .NET Framework 4 是否为此提供了一些内置工具集?
【问题讨论】:
我将一个名为 LHA Decompressor 的 LHA Java 解压缩库移植到 .NET。
【讨论】:
非常感谢上面的作者。我已经发布了一个简单的实现以供参考。
//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();
【讨论】: