[
  {
    "Id": "171940",
    "ThreadId": "51285",
    "Html": "I'm working on a project that needs to use DotNetZip in &quot;pure streaming mode&quot; -- where both the input is a stream and the output is a stream (which is then ftp'ed). The code works fine for very small output, but even files only about 500K aren't readable as an xp or vista compressed folder. However, I know the end-to-end process works because the resulting output zip file (I've tested up to several megs) ARE readable by using DotNetZip to decompress them. Is there something basic I'm missing? I'm using version 1.7.2.12 of the library.<br>\r\n<br>\r\nHere's the little class I created (a bit overkill, but I'll be adding more customization later):<br>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;color:#0000ff;font-family:'courier new'\">class</span><span style=\"font-size:8pt;font-family:'courier new'\"> <span style=\"color:#2b91af\">Zip</span> : <span style=\"color:#2b91af\">ZipFile</span>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">    {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\"> </span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">        <span style=\"color:#0000ff\">internal</span> <span style=\"color:#0000ff\">bool</span> zipEncrypt(<span style=\"color:#2b91af\">Stream</span> inF, <span style=\"color:#2b91af\">Stream</span> outF, <span style=\"color:#2b91af\">SubscriptionData</span> subData, <span style=\"color:#0000ff\">string</span> fullFileName, <span style=\"color:#0000ff\">ref</span> <span style=\"color:#2b91af\">StringBuilder</span> m_sb)</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">        {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">            <span style=\"color:#0000ff\">using</span> (<span style=\"color:#2b91af\">ZipFile</span> myZip = <span style=\"color:#0000ff\">new</span> <span style=\"color:#2b91af\">ZipFile</span>())</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">            {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                <span style=\"color:#0000ff\">try</span>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    <span style=\"color:#0000ff\">if</span> (subData.UseZipPassword)</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                        myZip.Password = subData.ZipPassword;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                        myZip.Encryption = <span style=\"color:#2b91af\">EncryptionAlgorithm</span>.PkzipWeak;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    }</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    <span style=\"color:#0000ff\">else</span>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                        myZip.Encryption = <span style=\"color:#2b91af\">EncryptionAlgorithm</span>.None;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\"> </span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    myZip.CompressionLevel = Ionic.Zlib.<span style=\"color:#2b91af\">CompressionLevel</span>.BEST_COMPRESSION;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    myZip.UseUnicodeAsNecessary = <span style=\"color:#0000ff\">false</span>;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    myZip.UseZip64WhenSaving = <span style=\"color:#2b91af\">Zip64Option</span>.AsNecessary;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\"> </span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    myZip.AddFileStream(fullFileName.Replace(<span style=\"color:#a31515\">&quot;.zip&quot;</span>,<span style=\"color:#a31515\">&quot;&quot;</span>), <span style=\"color:#a31515\">&quot;&quot;</span>, inF);</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    myZip.Save(outF);</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                }</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                <span style=\"color:#0000ff\">catch</span> (<span style=\"color:#2b91af\">Exception</span> ex)</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                    <span style=\"color:#0000ff\">throw</span> ex;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                }</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                <span style=\"color:#0000ff\">return</span> <span style=\"color:#0000ff\">true</span>;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">            }</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">        }</span></p>\r\n<p style=\"margin:0in 0in 10pt\"><span style=\"font-size:8pt;line-height:115%;font-family:'courier new'\">    }</span> <br>\r\n<br>\r\nand here's how I'm calling it:<br>\r\n<br>\r\n<span style=\"font-size:8pt;font-family:'courier new'\">                        <span style=\"color:#0000ff\">using</span> (<span style=\"color:#2b91af\">Zip</span> myZip = <span style=\"color:#0000ff\">new</span> <span style=\"color:#2b91af\">Zip</span>())</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"> </p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                        {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                            <span style=\"color:#0000ff\">try</span>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                            {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                                <span style=\"color:#0000ff\">using</span> (<span style=\"color:#2b91af\">MemoryStream</span> encryptedStream = <span style=\"color:#0000ff\">new</span> <span style=\"color:#2b91af\">MemoryStream</span>())</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                                {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                                    inStream.Position = 0;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                                    myZip.zipEncrypt(inStream, encryptedStream, data, fullFileName, <span style=\"color:#0000ff\">ref</span> m_sb);</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                                    <span style=\"color:#0000ff\">this</span>.reportdata = encryptedStream.GetBuffer();</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                                }</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                                <span style=\"color:#0000ff\">return</span> <span style=\"color:#0000ff\">true</span>;</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                            }</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                            <span style=\"color:#0000ff\">catch</span> (<span style=\"color:#2b91af\">Exception</span> ex)</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                            {</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                                <span style=\"color:#0000ff\">…</span>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                            }</span></p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"><span style=\"font-size:8pt;font-family:'courier new'\">                        }</span></p>\r\n</span></p>\r\n<p>&nbsp;</p>\r\n<p> </p>\r\n<p> </p>\r\n</span></p>\r\n<p>&nbsp;</p>\r\n<p> </p>\r\n<p> </p>\r\n</span></p>\r\n<p>&nbsp;</p>\r\n<p> </p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"> </p>\r\n<p> </p>\r\n</span></p>\r\n<p>&nbsp;</p>\r\n<p> </p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"> </p>\r\n<p> </p>\r\n</span></p>\r\n<p>&nbsp;</p>\r\n<p> </p>\r\n<p style=\"margin:0in 0in 0pt;line-height:normal\"> </p>\r\n<p> </p>\r\n",
    "PostedDate": "2009-03-25T10:17:01.4-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "171956",
    "ThreadId": "51285",
    "Html": "<p>It should work the way you would like it to work. </p>\r\n<p>I'm not completely clear on what works and what does not. <br>\r\nWhen  you say &quot;the entire process works&quot; - have you tried reading the &quot;multi-meg&quot; result in Windows XP Compressed folders?  </p>\r\n<p>Is is the size that makes the difference ?  Or is it the streaming part?  Or both? <br>\r\nAre you saying that files above about 500k are not readable? <br>\r\nor files created with streaming, above 500k, are not readable?  <br>\r\nor... <br>\r\n<br>\r\nI'll take a look at your code when I get a chance.</p>\r\n",
    "PostedDate": "2009-03-25T11:03:53.143-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "171960",
    "ThreadId": "51285",
    "Html": "<p>sorry for being vague:</p>\r\n<p>using the exact code above, if I zip a small stream (I don't know the exact size, but it represents a report based on a 10,000 row table), it is fully readable as a Windows compressed folder and reports is full size as 108K (compressed to 25K). If I rerun the same code reading a 100,000 row version of the same report, it is decompressible using the ZipEntry.Extract method, but can't be opened using built in Windows compressed folders or via WinZip. The output file appears to be compressed -- the uncompressed version of the file I create is about 1.2M while the unreadable zip file is 514K.</p>\r\n",
    "PostedDate": "2009-03-25T11:17:33.95-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "172134",
    "ThreadId": "51285",
    "Html": "ok I will have a look, see what I can figure out. \r\n",
    "PostedDate": "2009-03-25T20:35:58.793-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "172502",
    "ThreadId": "51285",
    "Html": "<p>I tried but was not able to reproduce this behavior you reported.<br>\r\n<br>\r\nI have some concerns about your code, though.  The Zip class you have defined, derives from Ionic.ZipFile, I guess.  But it exposes a single method, zipEncrypt(), which creates a ZipFile, without ever using the base class. So I don't understand why you would derive your class from ZipFile?  In fact your Zip class defines no member variables or methods - and so the zipEncrypt() method can and probably should be defined as a static method.  <br>\r\n<br>\r\nAlso, the StringBuilder parameter to the zipEncrypt method is never used. <br>\r\nI also don't understand what you are doing with the code that removes the extension from the fullfilename.  (fullFilename.Replace(&quot;.zip&quot;, &quot;&quot;)) <br>\r\nAnd that code suggests that you may be adding a zip file into a zip file, which... also doesn't make sense to me.  Why would you embed a zipfile into a zipfile?<br>\r\n<br>\r\nAlso, your code does not show how the output stream gets saved to a file, which I guess you would need to do, if you try to open it with WinZip.  <br>\r\nWith all these questions, I'm not sure what to think.  <br>\r\n<br>\r\nCan you produce a standalone test case, preferably a console app, that reliably reproduces the problem you've described?   and can you send me that code? <br>\r\n</p>\r\n<p> <br>\r\n </p>\r\n",
    "PostedDate": "2009-03-26T13:40:19.283-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173018",
    "ThreadId": "51285",
    "Html": "I had pulled out a lot of the code, so it had some things that looked unused.<br>\r\n<br>\r\nIt turned out to be my GetBuffer() call, when I read the now-zip-compressed data in the memorystream (<span style=\"color:#0000ff\">this</span>.reportdata = encryptedStream.GetBuffer();) it was somehow corrupting the data, although the finished file was the correct size. When I changed the .GetBuffer() to .ToArray() it worked fine.\r\n",
    "PostedDate": "2009-03-27T23:38:44.653-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "173020",
    "ThreadId": "51285",
    "Html": "Glad you were able to figure it out! \r\n",
    "PostedDate": "2009-03-28T00:24:35.053-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]