我在使用2000年的Windows版本4的旧PKZIP®命令行创建的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;
}
}你知道怎么解决这个问题吗?
发布于 2019-09-06 06:27:37
我在解压一个用7-zip压缩的zip文件时也遇到了同样的问题。
我把它从Deflate64改成了Deflate,然后它就起作用了。

https://stackoverflow.com/questions/34341905
复制相似问题