繁体   English   中英

ICSharpCode.SharpZipLib 压缩方法不支持 PKZIP

[英]ICSharpCode.SharpZipLib Compression method not supported PKZIP

我在使用旧 PKZIP® 命令行为 Windows 2000 年版本 4 创建的 zip 文件时遇到问题。我正在使用 ICSharpCode.SharpZipLib 来提取文件。 Windows 在资源管理器中打开文件没有问题。 这是代码:

private void Extract(string zipFile, string outputfolder)
{
  try
  {
    _logger.InfoFormat("Extracting {0}", zipFile);
    System.IO.Stream stream = new System.IO.FileStream(zipFile, System.IO.FileMode.Open);
    ZipInputStream zipInputStream = new ZipInputStream(stream);
    ZipEntry zipEntry = zipInputStream.GetNextEntry(); //Throws Compression error exception
    while (zipEntry != null)
    {
      String entryFileName = zipEntry.Name;
      _logger.InfoFormat("Entry-Filename: {0}", entryFileName);

      byte[] buffer = new byte[4096];
      String fullZipToPath = Path.Combine(outputfolder, entryFileName);
      string directoryName = Path.GetDirectoryName(fullZipToPath);
      if (directoryName.Length > 0)
      {
        Directory.CreateDirectory(directoryName);
      }

      using (FileStream streamWriter = File.Create(fullZipToPath))
      {
        StreamUtils.Copy(zipInputStream, streamWriter, buffer);
      }
      zipEntry = zipInputStream.GetNextEntry();
    }
  }
  catch (Exception ex)
  {
    _logger.Error("Error during extraction",ex);
    throw;
  }
}

知道如何解决这个问题吗?

解压缩使用 7-zip 制作的 zip 文件时,我遇到了同样的问题。

我将它从 Deflate64 更改为 Deflate,然后它工作了。

显示压缩方法的 7-zip 屏幕截图

更新到版本 1.3.3 解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM