I have many files and I want to add thems in to a new zipfile. I used this nameespace : using 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:
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.
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.