我在c#写一个方法压缩文件夹成zip格式压缩后的压缩包在用java写的代码中解压报错 急求!!!!!!!!!

这是c#端代码java端代码没错
/// <summary>
/// 压缩文件
/// </summary>
/// <param name="dir">文件目录</param>
/// <param name="zipfilename">zip文件名</param>
public static void compressFiles(string dir, string zipfilename)
{
if (!Directory.Exists(dir))
{
//ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script defer>alert('目录不存在,请联系管理员。');</script>");
return;
}
try
{
string[] filenames = Directory.GetFiles(dir);
using (ZipOutputStream s = new ZipOutputStream(File.Create(zipfilename)))
{

s.SetLevel(9); // 0 - store only to 9 - means best compression

byte[] buffer = new byte[4096];

foreach (string file in filenames)
{
ZipEntry entry = new ZipEntry(Path.GetFileName(file));
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);

using (FileStream fs = File.OpenRead(file))
{
int sourceBytes;
do
{
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
} while (sourceBytes > 0);
}
}
s.Finish();
s.Close();
}
}
catch
{

}
}

第1个回答  2013-03-20
先输出异常在哪里,在解决
相似回答