簡體   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