【问题标题】:Extract file from LZH archive从 LZH 存档中提取文件
【发布时间】:2015-12-13 00:36:33
【问题描述】:

我有 LZH 存档(存档的.lzh、.lha 扩展名),并且需要在 .NET Framework 4 中从中提取文件? .NET Framework 4 是否为此提供了一些内置工具集?

【问题讨论】:

标签: c# .net archive


【解决方案1】:

我将一个名为 LHA Decompressor 的 LHA Java 解压缩库移植到 .NET。

【讨论】:

    【解决方案2】:

    非常感谢上面的作者。我已经发布了一个简单的实现以供参考。

                //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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-31
      • 2013-10-16
      • 2021-08-19
      • 1970-01-01
      • 1970-01-01
      • 2014-09-10
      相关资源
      最近更新 更多