SharpZipLib 异常 Wrong Local header signature: 0x90014

.Net技术 针尖舞 9年前 (2015-08-26) 3541次浏览 0个评论
 

 

using ICSharpCode.SharpZipLib.Zip;

using ICSharpCode.SharpZipLib.GZip;

using ICSharpCode.SharpZipLib.BZip2;

using ICSharpCode.SharpZipLib.Checksums;

using ICSharpCode.SharpZipLib.Zip.Compression;

using ICSharpCode.SharpZipLib.Zip.Compression.Streams;

  /**//// <summary>

  /// 解压文件

  /// </summary>

  /// <param name=”args”>包含要解压的文件名和要解压到的目录名数组</param>

  public void UnZip(string[] args)

  {

  ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));

  try

  {   

  ZipEntry theEntry;

  while ((theEntry = s.GetNextEntry()) != null) //出错位置

  {   

  string directoryName = Path.GetDirectoryName(args[1]);

  string fileName = Path.GetFileName(theEntry.Name);

    

  //生成解压目录

  Directory.CreateDirectory(directoryName);

    

  if (fileName != String.Empty)  

  {   

  //解压文件到指定的目录

  FileStream streamWriter = File.Create(args[1]+fileName);

    

  int size = 2048;

  byte[] data = new byte[2048];

  while (true)  

  {

  size = s.Read(data, 0, data.Length);

  if (size > 0)  

  {

  streamWriter.Write(data, 0, size);

  }  

  else  

  {

  break;

  }

  }

    

  streamWriter.Close();

  }

  }

  s.Close();

  }

  catch(Exception eu)

  {

  throw eu;

  }

  finally

  {

  s.Close();

  }

  }

以上代码报有异常:Wrong Local header signature: 0x90014

 

————

 

原来使用过的,或用winrar,实现

public void UnZip(string[] args)

{

ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));

  

ZipEntry theEntry;

while ((theEntry = s.GetNextEntry()) != null) 

{

string directoryName = Path.GetDirectoryName(args[1]);

string fileName      = Path.GetFileName(theEntry.Name);

Directory.CreateDirectory(directoryName);

if (fileName != String.Empty) 

{   

//解压文件到指定的目录

FileStream streamWriter = File.Create(args[1]+theEntry.Name);

    

int size = 2048;

byte[] data = new byte[2048];

while (true) 

{

size = s.Read(data, 0, data.Length);

if (size > 0) 

{

streamWriter.Write(data, 0, size);

else 

{

break;

}

}

streamWriter.Close();

}

}

s.Close();

}

调用

string []FileProperties=new string[2];

FileProperties[0]=strPath; //待解压的文件

FileProperties[1]=strPhotoPath+@””;//解压后放置的目标目录

UnZip(FileProperties);

 

额?怎么没看出和我的有什么不同啊

 

这个SharpZipLib怎么回事啊?以后不了解,真的不能随便用了……

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明SharpZipLib 异常 Wrong Local header signature: 0x90014
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!