[
  {
    "Id": "207628",
    "ThreadId": "61221",
    "Html": "<p>Hi all,</p>\r\n<p>I'm a relatively new user of the DotNetZip library and I'm experiencing the following problem: When I try to zip a small file (eg. 3 bytes) and encrypt it as well I get the following error on the zip.Save statement:</p>\r\n<p><span style=\"font-size:small;font-family:Courier New\">An attempt was made to move the position before the beginning of the stream. () </span></p>\r\n<p>This error does not occur when the file content is larger or when the file is 0 bytes. However, when the size is zero bytes I don't seem to be able to open the file using the password. A 'CRC failed in encrypted file 'filename'. Wrong password ?' is generated. I'm sure the password is correct. When the file contains content this works ok.</p>\r\n<p>Thanks for any help or pointers.</p>\r\n<p>boris</p>\r\n<p>This is the code snippet I'm using:</p>\r\n<p><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">private</span></span><span style=\"font-size:x-small\"> </span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">static</span></span><span style=\"font-size:x-small\"> </span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">MemoryStream</span></span><span style=\"font-size:x-small\"> ZipAndEncryptReport(</span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">MemoryStream</span></span><span style=\"font-size:x-small\"> report, </span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">INotifierInstanceTemplate</span></span><span style=\"font-size:x-small\"> template, </span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">string</span></span><span style=\"font-size:x-small\"> filename)<br>{</span></p>\r\n<p>\r\n<p><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">if</span></span><span style=\"font-size:x-small\"> (template.ZipReport &amp;&amp; template.Type != </span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">TemplateType</span></span><span style=\"font-size:x-small\">.EmailContent)<br>{<br></span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">MemoryStream</span></span><span style=\"font-size:x-small\"> zippedStream = </span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">new</span></span><span style=\"font-size:x-small\"> </span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">MemoryStream</span></span><span style=\"font-size:x-small\">();<br></span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">ZipFile</span></span><span style=\"font-size:x-small\"> zip = </span><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">new</span></span><span style=\"font-size:x-small\"> </span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">ZipFile</span></span><span style=\"font-size:x-small\">();<br>report.Seek(0, </span><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">SeekOrigin</span></span><span style=\"font-size:x-small\">.Begin); &lt;font size=&quot;2&quot;&gt;\r\n<p>log.InfoFormat(</p>\r\n&lt;/font&gt;</span></p>\r\n<p><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;The output for the report &lt;{0}&gt; is zipped.&quot;</span></span><span style=\"font-size:x-small\">, filename);&lt;font size=&quot;2&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;</span></p>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">if</span></span><span style=\"font-size:x-small\"> (template.EncryptReport)<br></span><span style=\"font-size:x-small\">{<br>log.InfoFormat(</span><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;The output for the report &lt;{0}&gt; is encrypted with AES 256.&quot;</span></span><span style=\"font-size:x-small\">, filename);&lt;font size=&quot;2&quot;&gt;\r\n<p>zip.Password = template.EncryptPassword;<br>zip.Encryption =</p>\r\n&lt;/font&gt;</span></p>\r\n<p><span style=\"font-size:x-small;color:#2b91af\"><span style=\"font-size:x-small;color:#2b91af\">EncryptionAlgorithm</span></span><span style=\"font-size:x-small\">.WinZipAes256;<br>}&lt;font size=&quot;2&quot;&gt;\r\n<p>zip.AddFileStream(filename,</p>\r\n&lt;/font&gt;</span></p>\r\n<p><span style=\"font-size:x-small;color:#a31515\"><span style=\"font-size:x-small;color:#a31515\">&quot;&quot;</span></span><span style=\"font-size:x-small\">, report);<br>zip.Save(zippedStream);&lt;font size=&quot;2&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;</span></p>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">return</span></span><span style=\"font-size:x-small\"> zippedStream;<br>}&lt;font size=&quot;2&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;</span></p>\r\n<p><span style=\"font-size:x-small\">}&lt;font size=&quot;2&quot;&gt;\r\n<p>&nbsp;</p>\r\n&lt;/font&gt;</span></p>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-size:x-small;color:#0000ff\"><span style=\"font-size:x-small;color:#0000ff\">return</span></span><span style=\"font-size:x-small\"> report;</span></p>\r\n<p>}</p>\r\n</p>",
    "PostedDate": "2009-07-01T10:08:55.953-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "207667",
    "ThreadId": "61221",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=7967\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-07-01T11:39:10.523-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "207768",
    "ThreadId": "61221",
    "Html": "<p>Boris, I had an arithmetic error in the code. Can you try v1.8.4.1 ?</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-07-01T17:49:24.097-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]