ICSharp code.SharpZipLib.Zip CRC32 [英] ICSharpCode.SharpZipLib.Zip crc32

查看:461
本文介绍了ICSharp code.SharpZipLib.Zip CRC32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ICSharp code.SharpZipLib.Zip对COM preSS的文件和文件夹的使用response.Binary写的MemoryStream传递。

I am using ICSharpCode.SharpZipLib.Zip to compress the files and folders and pass it as memorystream using response.Binary write.

下面是我的code:

MemoryStream df= new MemoryStream();                
ZipOutputStream s = new ZipOutputStream(df);
s.SetLevel(9);

byte[] data = (byte[])file.OpenBinary();
s.Write(data, 0, data.Length);
s.Finish();

s.Close();
byte[] outBuf = df.GetBuffer();        
Response.Expires = 0;                 
Response.Buffer = true;                 
Response.ClearContent();                
Response.AddHeader("content-disposition", "inline; filename="out.zip");
Response.ContentType = "application/zip";
Response.BinaryWrite(outBuf);
HttpContext.Current.ApplicationInstance.CompleteRequest();

当我尝试打开out.zip文件,它是说,zip文件已损坏或
损坏,CRC值是显示为000000。

When I try to open the out.zip file, it is saying that the zip file is either corrupted or damaged, and the crc value is showing as 000000.

,这是什么解决办法吗?
为什么这个错误发生?

What is the solution for this? Why is this error is occurring?

推荐答案

我会采取一种猜测,你应该叫:

I'd take a guess, you should call:

s.Flush();
df.Flush();

您调用就在 df.GetBuffer()

这篇关于ICSharp code.SharpZipLib.Zip CRC32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆