[
  {
    "Id": "918382",
    "ThreadId": "397137",
    "Html": "\r\n<p>Hi there,</p>\r\n<p>Struggling to get my code working for adding a collection of Byte files from the database into a zip file to download on the fly.&nbsp; Can anyone give me a point in the right direction?&nbsp; I'm using the latest version.</p>\r\n<p>Here's what I have so far:</p>\r\n<p></p>\r\n<pre>string folder = dtFiles[0].UploadGuid;\r\nstring zipName = (dtProof[0].Name &#43; &quot;_&quot; &#43; dtProof[0].Postcode).Replace(&quot; &quot;, &quot;&quot;) &#43; &quot;.zip&quot;;\r\n\r\ntry\r\n{\r\n    Response.Clear();\r\n    Response.BufferOutput = false;\r\n    Response.ContentType = &quot;application/zip&quot;;\r\n    Response.AddHeader(&quot;content-disposition&quot;, &quot;filename=&quot; &#43; zipName);\r\n    MemoryStream ms = new MemoryStream();\r\n    using (ZipOutputStream zip = new ZipOutputStream(ms))\r\n    {   \r\n        foreach (DataRow row in dtFiles)\r\n        {\r\n            Byte[] fileByte = (Byte[])row[&quot;FileBinary&quot;];\r\n            zip.PutNextEntry(row[&quot;Filename&quot;].ToString());\r\n            zip.Write(fileByte, 0, fileByte.Length);\r\n        }\r\n        Response.OutputStream.Write(zip);\r\n    }\r\n\r\n    Response.Close();\r\n}</pre>\r\n<p></p>\r\n<p>The build fails at the Response.OutputStream line, but I'm not sure it's right even up to then.&nbsp;</p>\r\n<p>Any help appreciated.</p>\r\n<p>Ian</p>\r\n",
    "PostedDate": "2012-09-27T04:33:16.9-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "918664",
    "ThreadId": "397137",
    "Html": "<p>ZipOutStream is even writing to destination stream while disposing.&nbsp; So, when it is disposed (after using) instead use the MemoryStream for writing to Response stream.</p>\r\n<p>Another idea is to use ZipFile-object. After adding all files to it, finish with ZipFile.Save(Response.OutputStream).</p>",
    "PostedDate": "2012-09-27T11:56:49.25-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]