[
  {
    "Id": "915971",
    "ThreadId": "396476",
    "Html": "\r\n<p>Hi guys, getting an error when trying to output a zip file to a response stream. Its a zip of images.</p>\r\n<p>&nbsp;</p>\r\n<p>Error:&nbsp;{System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.&nbsp; &nbsp;at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array\r\n dst, Int32 dstOffset, Int32 count)&nbsp; &nbsp;at Ionic.Zip.ZipEntry.WriteHeader(Stream s, Int32 cycle)&nbsp; &nbsp;at Ionic.Zip.ZipEntry.Write(Stream s)&nbsp; &nbsp;at Ionic.Zip.ZipFile.Save()&nbsp; &nbsp;at Ionic.Zip.ZipFile.Save(Stream outputStream)&nbsp;\r\n &nbsp;at&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>Code Snippet 1 - &nbsp;adding images to a zip</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre>  <span style=\"color:blue\">foreach</span> (<span style=\"color:blue\">string</span> pic <span style=\"color:blue\">in</span> list)\r\n                        {\r\n                           \r\n                            <span style=\"color:blue\">byte</span>[] imageBytes = Convert.FromBase64String(pic);\r\n                            MemoryStream ms = <span style=\"color:blue\">new</span> MemoryStream(imageBytes);\r\n\r\n                            System.Drawing.Bitmap img = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);\r\n                            \r\n                            zip.AddEntry(pic &#43; <span style=\"color:#a31515\">&quot;.bmp&quot;</span>, imageBytes);\r\n\r\n                        \r\n                       \r\n                        }\r\n\r\n</pre>\r\n</div>\r\n<p></p>\r\n<p>}</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>Code Snippet 2 - Outputing the &nbsp;zip</p>\r\n<p>&nbsp;</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre>                  Response.ContentType = <span style=\"color:#a31515\">&quot;application/zip&quot;</span>;\r\n                  Response.AddHeader(<span style=\"color:#a31515\">&quot;content-disposition&quot;</span>, <span style=\"color:#a31515\">&quot;filename=&quot;</span> &#43; filename);\r\n                 zip.Save(Response.OutputStream);\r\n                 Response.Flush();\r\n</pre>\r\n</div>\r\n<p></p>\r\n<p>&nbsp;</p>\r\n<p>Any ideas? The error is actually coming from DLL itself. Whats the best way to debug this?&nbsp;</p>\r\n",
    "PostedDate": "2012-09-21T17:10:42.433-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]