[英]Error occured in saved zip file+using Ionic.Zip
I have many files and I want to add thems in to a new zipfile. 我有很多文件,我想将它们添加到新的zipfile中。 I used this nameespace : using Ionic.Zip
我使用了这个nameespace:使用Ionic.Zip
here my codes: 这是我的代码:
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");
now when I open the saved zip file,this error occured: 现在,当我打开保存的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
From the snippet I see, I assume that zip is a Ionic.Zip.ZipFile instance, if not please provide more information. 从我看到的代码片段中,我假定zip是Ionic.Zip.ZipFile实例,如果没有,请提供更多信息。
ZipFile.Save(Stream) writes to the stream, and again from what I can see from that snippet it appears that you're trying to write to a Response stream, instead of reading from it. ZipFile.Save(流) 写入流,再从我可以从该段看 ,似乎你想要的,而不是从中读取到写入响应流。
Please provide more info and I will try to help you further. 请提供更多信息,我会尽力帮助您。
You should try Zipping from the path instead from a stream. 您应该尝试从路径而非流中压缩。
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.