首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ICSharpCode.SharpZipLib压缩方法不支持PKZIP

ICSharpCode.SharpZipLib压缩方法不支持PKZIP
EN

Stack Overflow用户
提问于 2015-12-18 02:38:36
回答 1查看 2.1K关注 0票数 0

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

代码语言:javascript
复制
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;
  }
}

你知道怎么解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2019-09-06 06:27:37

我在解压一个用7-zip压缩的zip文件时也遇到了同样的问题。

我把它从Deflate64改成了Deflate,然后它就起作用了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34341905

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档