[英]How to fix zip file corrupt error while downloading large files with Ionic-zip in c#
[英]converting documents to zip file, Added files and downloading, but while opening getting error
成功将文档添加到zip中,添加条目并下载它。
但是在打开例如Doc1,Doc2时,如果我仅下载doc1(下载并查看成功)
如果我尝试下载它的doc2,但是在打开时(无法打开文件,它似乎不是有效的档案,请再试一次,这是打开时的消息)。 如果我同时检查并下载,并且下载成功,则可以将其打开。
任何帮助,不胜感激
ZipFile zip = new ZipFile();
foreach (GridDataItem item in RadGridSearchResults.MasterTableView.Items)
{
int documid;
bool chec;
CheckBox check = (CheckBox)item.FindControl("CheckBox1");
DocDetails dd = new DocDetails();
if (check.Checked == true)
{
documid = Convert.ToInt32(item["DOCUMENT_ID"].Text);
Document document = Document.GetDocumentByDocumentId(documid);
zip.AddEntry(document.DocumentName, document.DocumentFileImage);
}
}
var zipMs = new MemoryStream();
zip.Save(zipMs);
byte[] fileData = zipMs.GetBuffer();
zipMs.Seek(0, SeekOrigin.Begin);
zipMs.Flush();
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=docs.zip ");
Response.ContentType = "application/zip";
Response.BinaryWrite(fileData);
Response.End();
我通过使用解决了
using ICSharpCode.SharpZipLib.Zip;
通过使用(使用Ionic.Zip;)此数据在内部损坏,甚至不引发异常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.