![](/img/trans.png)
[英]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.