[英]Error occured in saved zip file+using Ionic.Zip
我有很多文件,我想將它們添加到新的zipfile中。 我使用了這個nameespace:使用Ionic.Zip
這是我的代碼:
for (int i = 0; i < deliveryList.Count; i++)
{
// System.IO.MemoryStream st = new System.IO.MemoryStream(x.Data.Data);
zip.AddEntry(x.StudentObj.Number.ToString() + '.' + t[t.Length -1 ],x.Data.Data);
}
zip.Save(Response.OutputStream); //"Archive.zip");
現在,當我打開保存的zip文件時,發生此錯誤:
C:\Users\Sara\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5\D6IMASPE\TExamGrades.zip: The archive is either in unknown format or damaged
從我看到的代碼片段中,我假定zip是Ionic.Zip.ZipFile實例,如果沒有,請提供更多信息。
ZipFile.Save(流) 寫入流,再從我可以從該段看 ,似乎你想要的,而不是從中讀取到寫入響應流。
請提供更多信息,我會盡力幫助您。
您應該嘗試從路徑而非流中壓縮。
Dim zip = New Ionic.Zip.ZipFile()
Try
zip.AddFile(NameFile1,PathFile1)
zip.AddFile(NameFile2,PathFile2)
zip.AddFile(NameFile3,PathFile3)
zip.Save(sZipDestinyPat)
Catch ex As Exception
ZipDirectory = -1
End Try
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.