各位帮我看看哪里错了

linq-w 2010-05-14 01:44:54


using System;
using System.Text;
using System.Collections;
using System.IO;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters.Binary;
using System.Data;

using ICSharpCode.SharpZipLib.BZip2;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using ICSharpCode.SharpZipLib.GZip;

namespace Compress
{
public class UnZipClass
{
public void UnZip(string[] args)
{
ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));

ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)//这里错了Unexpected EOF
{

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();
}
}
}

...全文
152 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
noway8881 2010-05-14
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 caozhy 的回复:]
文件名是否被正确传入?如果路径有空格,要用引号包起来。
[/Quote]

正解。
zzx509 2010-05-14
  • 打赏
  • 举报
回复
这个是它自己的压缩方法,应该是基于GZIP的。
要解压必须也要调这个dll来解。
mayonglong 2010-05-14
  • 打赏
  • 举报
回复
最好把问题说清楚~
linq-w 2010-05-14
  • 打赏
  • 举报
回复
压缩好了以后是能用winrar来解压的,但是这个却不能
烈火蜓蜻 2010-05-14
  • 打赏
  • 举报
回复
那是你压缩的文件没有办法用这个来解开
threenewbee 2010-05-14
  • 打赏
  • 举报
回复
文件名是否被正确传入?如果路径有空格,要用引号包起来。
deknight 2010-05-14
  • 打赏
  • 举报
回复
while ((theEntry = s.GetNextEntry())
断点,theEntry 等于什么?
苦苦挣扎中 2010-05-14
  • 打赏
  • 举报
回复
是不是该文件不能解压?你用解压工具先解压看下

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧