[
  {
    "Id": "449928",
    "ThreadId": "214550",
    "Html": "<p>Hello,</p>\r\n<p>In almost all cases library works perfectly. But in some cases I am getting damaged archive and strange &quot;$&quot; entry inside.&nbsp;</p>\r\n<p>I am getting this especially when file (I am zipping xml files) contains attribute with a lot of byte data.</p>\r\n<p>When I am trying to open archive I get: &quot;ArchivedResults.zip: Unexpected end of archive&quot;</p>\r\n<p>Is there anybody who faced such problem?</p>\r\n<p>&nbsp;</p>\r\n<p>Thanks.</p>",
    "PostedDate": "2010-06-01T02:44:28.73-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "451096",
    "ThreadId": "214550",
    "Html": "<p>If xml doesn't contains base64 data then it works. Since WriteXml method encode byte array to base64 string I get error in zip archive.&nbsp;</p>",
    "PostedDate": "2010-06-03T02:41:17.76-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "451136",
    "ThreadId": "214550",
    "Html": "<p>Can you show me some code that produces the error. A simple test case.</p>\r\n<p>How do you add entries to the archive?</p>",
    "PostedDate": "2010-06-03T04:42:42.677-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "451142",
    "ThreadId": "214550",
    "Html": "<p><span style=\"font-family:Consolas, 'Courier New', Courier, monospace\"><span style=\"white-space:pre\"><span style=\"font-family:'Segoe UI', 'Microsoft Sans Serif', Arial, Geneva, sans-serif\"><span style=\"white-space:normal\">Thanks for answering.<br><br><br> </span></span></span></span></p>\r\n<div style=\"color:black;background-color:white\">\r\n<pre>MemoryStream ms = <span style=\"color:blue\">new</span> MemoryStream();\r\n\t\t\t<span style=\"color:blue\">using</span> (ZipFile zip = <span style=\"color:blue\">new</span> ZipFile())\r\n\t\t\t{\r\n\t\t\t\t<span style=\"color:blue\">using</span> (Stream s = GetStream(_transformatedFileName, FileMode.Open))\r\n\t\t\t\t{\r\n\t\t\t\t\tzip.AddEntry(<span style=\"color:#a31515\">&quot;Results.xml&quot;</span>, s);\r\n\t\t\t\t\tzip.CompressionLevel = CompressionLevel.BestCompression;\r\n\r\n\t\t\t\t\tzip.Save(ms);\r\n\r\n\t\t\t\t\t<span style=\"color:green\">//zip.Save(@&quot;C:\\\\Downloads\\Results.zip&quot;);</span>\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n</pre>\r\n</div>\r\n<p>&nbsp;</p>\r\n<p><br><br>Then send ms object over WCF inside resultMessage (OutputStream contains archived stream)<br>After I receive message I am writing it to the hard disk:</p>\r\n<p>&nbsp;</p>\r\n<div style=\"color:black;background-color:white\">\r\n<pre><span style=\"color:blue\">using</span>(Stream s = GetStream(filepath, FileMode.Create))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t<span style=\"color:green\">//Read byte array from OutputStream</span>\r\n\t\t\t\t\t\t<span style=\"color:blue\">byte</span>[] byteArray = <span style=\"color:blue\">new</span> <span style=\"color:blue\">byte</span>[resultMessage.OutputStream.Length];\r\n\t\t\t\t\t\t<span style=\"color:blue\">int</span> count = resultMessage.OutputStream.Read(byteArray, 0, (<span style=\"color:blue\">int</span>)resultMessage.OutputStream.Length);\r\n\r\n\t\t\t\t\t\t<span style=\"color:green\">//Write to isolated storage</span>\r\n\t\t\t\t\t\ts.Write(byteArray,0, byteArray.Length);\r\n\t\t\t\t\t}\r\n</pre>\r\n</div>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-family:Consolas, 'Courier New', Courier, monospace\"><span style=\"white-space:pre\"><span style=\"font-family:'Segoe UI', 'Microsoft Sans Serif', Arial, Geneva, sans-serif\"><span style=\"white-space:normal\"><br>An hour ago I noticed that problem is in sending it over WCF. If instead it I just save it to hard disk then it works.<br><br><br><br><br></span></span></span></span></p>",
    "PostedDate": "2010-06-03T05:00:57.97-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "451198",
    "ThreadId": "214550",
    "Html": "<p>Ahh, Well then it seems like it is not a problem in DotNetZip.</p>\r\n<p>The most common problem when saving to a MemoryStream is that people forget to call .Seek() on the memory stream, after writing it, and before reading it. There were 2 people this week that had this problem.&nbsp; Maybe that's your problem here. If I'm right, you'd need to call <strong>ms.Seek(0, SeekOrigin.Begin)</strong> before transmitting ms over the WCF response.</p>\r\n<p>Good luck!</p>",
    "PostedDate": "2010-06-03T07:09:29.193-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "451204",
    "ThreadId": "214550",
    "Html": "<p>Probably you are right. maybe somewhere I didn't set position of stream to 0. I have a very big flow of data. So it is hard to find where is the problem. But after your questions</p>\r\n<p>I analyze all flow and understand that something wrong is with stream or WCF. Anyway thanks on quick answering.</p>",
    "PostedDate": "2010-06-03T07:28:28.51-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]