TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dhanesh P Menon
NA
17
2k
Invalid zip file when I use Ionic.Zip library to zip
Jan 19 2017 12:36 PM
My application is using Ionic.Zip library to zip the file. Using DataTables and each DataTable would create an excel file and download them as a single excel file.
But when i download the file, through the windows, i cannot able to open the zip file and it shows invalid error. But with the help of WinZip, i can do it. Can anyone of you please advise why this strange thing occurs. My code below,
using (ZipFile zip = new ZipFile())
{
MemoryStream memoryStream = new MemoryStream();
foreach (KeyValuePair<string, DataTable> doc in attachmentColl)
{
using (ExcelPackage objExcelPackage = new ExcelPackage())
{
memoryStream = new MemoryStream();
ExcelWorksheet objWorksheet = objExcelPackage.Workbook.Worksheets.Add(doc.Key);
objWorksheet.Cells["A1"].LoadFromDataTable(doc.Value, true);
zip.AddEntry(doc.Key + ".xlsx", objExcelPackage.GetAsByteArray());
}
}
Response.Clear();
Response.BufferOutput = false;
string zipName = String.Format("Reports.zip");
Response.AppendHeader("content-disposition", "attachment; filename=" + zipName);
Response.ContentType = "application/x-zip-compressed";
zip.Save(Response.OutputStream);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
Thanks in advance.
Reply
Answers (
1
)
How to display data and its title dynamically from database
Speech kannada Text Coding Asp.net