This project is read-only.

DotNetZip -Offset and length were out of bounds for the array

Sep 22, 2012 at 1:10 AM

Hi guys, getting an error when trying to output a zip file to a response stream. Its a zip of images.


Error: {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.   at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)   at Ionic.Zip.ZipEntry.WriteHeader(Stream s, Int32 cycle)   at Ionic.Zip.ZipEntry.Write(Stream s)   at Ionic.Zip.ZipFile.Save()   at Ionic.Zip.ZipFile.Save(Stream outputStream)   at 


Code Snippet 1 -  adding images to a zip

  foreach (string pic in list)
                            byte[] imageBytes = Convert.FromBase64String(pic);
                            MemoryStream ms = new MemoryStream(imageBytes);

                            System.Drawing.Bitmap img = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(ms);
                            zip.AddEntry(pic + ".bmp", imageBytes);





Code Snippet 2 - Outputing the  zip


                  Response.ContentType = "application/zip";
                  Response.AddHeader("content-disposition", "filename=" + filename);


Any ideas? The error is actually coming from DLL itself. Whats the best way to debug this?