Hi.
I have recently started using the ZipLibrary and I am facing an issue when adding streams to a ZipPackage. I am trying to add two streams to the ZipPackage, one for a PowerPoint file and the other for a Excel file. Once it is packaged, I want to write it to the OutputStream. Before I add the streams to the package, their size is significantly larger and have data because when I export them as individual streams (outside of a zip) it works just fine. Once added it looks like they lose all of their data and when it outputs, the PPTX and XLSX files are empty and corrupt respectively.
Here is my code below as well as the SendZipToClient snippet from another forum post, is there anything wrong with it or is it an issue from the ZipLibrary?
Additional Info:
.NET version: 4.5
Current Browser: FireFox 21.0
Telerik version for ASP.NET AJAX: 2013.1.417.45
Language: C#
I have recently started using the ZipLibrary and I am facing an issue when adding streams to a ZipPackage. I am trying to add two streams to the ZipPackage, one for a PowerPoint file and the other for a Excel file. Once it is packaged, I want to write it to the OutputStream. Before I add the streams to the package, their size is significantly larger and have data because when I export them as individual streams (outside of a zip) it works just fine. Once added it looks like they lose all of their data and when it outputs, the PPTX and XLSX files are empty and corrupt respectively.
Here is my code below as well as the SendZipToClient snippet from another forum post, is there anything wrong with it or is it an issue from the ZipLibrary?
Additional Info:
.NET version: 4.5
Current Browser: FireFox 21.0
Telerik version for ASP.NET AJAX: 2013.1.417.45
Language: C#
private void StreamReports(Dictionary<int, MemoryStream> ReportStreams){ string destPPTXFile = string.Format("{0}.pptx", txtPresentationName.Text); string destXLSXFile = string.Format("{0}.xlsx", txtPresentationName.Text); MemoryStream outputStream = new MemoryStream(); ZipPackage zipPackage = ZipPackage.Create(outputStream); MemoryStream powerpointStream = ReportStreams[0]; MemoryStream excelStream = ReportStreams[1]; zipPackage.AddStream(powerpointStream, destPPTXFile); zipPackage.AddStream(excelStream, destXLSXFile); SendZipToClient(outputStream, zipPackage); }private void SendZipToClient(MemoryStream memStream, ZipPackage Package) { string destFile = string.Format("{0}.zip", txtPresentationName.Text); Package.Close(false); memStream.Position = 0; if (memStream != null && memStream.Length > 0) { Response.Clear(); Response.AddHeader("content-disposition", "attachment; filename=\"" + destFile); Response.ContentType = "application/zip"; Response.BufferOutput = false; // to prevent buffering byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = memStream.Read(buffer, 0, buffer.Length)) > 0) { Response.OutputStream.Write(buffer, 0, bytesRead); } Response.End(); } }