[
  {
    "Id": "183264",
    "ThreadId": "54375",
    "Html": "Hi<br>\r\nI'm trying to use this excellent component with this code from ASP.NET web page.<br>\r\nI use ASP.NET 2.0, Windows XP, Ionic.Zip.dll 1.7.2.12 <br>\r\n<br>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#0000ff\"><span style=\"font-size:13px;color:#008000\"><span style=\"font-size:13px;color:#008000\">\r\n<p>&nbsp;</p>\r\n<p>'get data from database</p>\r\n</span>\r\n<p>&nbsp;</p>\r\n</span>\r\n<p>Dim</p>\r\n</span>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px\"> name </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String</span><span style=\"font-size:13px\"> = </span><span style=\"font-size:13px;color:#a31515\">&quot;&quot;<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> dt </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> System.Data.DataTable = </span><span style=\"font-size:13px;color:#0000ff\">Nothing<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> obj </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">New</span><span style=\"font-size:13px\"> clsSysFields(1, 1)<br>\r\nobj.funGetData(dt)<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> str </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">New</span><span style=\"font-size:13px\"> StringBuilder()<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">For</span><span style=\"font-size:13px\"> i </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">Integer</span><span style=\"font-size:13px\"> = 0 </span><span style=\"font-size:13px;color:#0000ff\">To</span><span style=\"font-size:13px\"> dt.Rows.Count - 1<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">    For</span><span style=\"font-size:13px\"> j </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">Integer</span><span style=\"font-size:13px\"> = 2 </span><span style=\"font-size:13px;color:#0000ff\">To</span><span style=\"font-size:13px\"> dt.Columns.Count - 1<br>\r\n        name = dt.Rows(i).Item(j).ToString + </span><span style=\"font-size:13px;color:#a31515\">&quot; &quot;<br>\r\n</span><span style=\"font-size:13px\">        str.Append(name.Substring(0, 20))<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">    Next<br>\r\n</span><span style=\"font-size:13px\">    str.AppendLine()<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">Next<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\"><br>\r\nDim</span><span style=\"font-size:13px\"> archiveName </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">String</span><span style=\"font-size:13px\"> = </span><span style=\"font-size:13px;color:#0000ff\">String</span><span style=\"font-size:13px\">.Format(</span><span style=\"font-size:13px;color:#a31515\">&quot;archive-{0}.zip&quot;</span><span style=\"font-size:13px\">, DateTime.Now.ToString(</span><span style=\"font-size:13px;color:#a31515\">&quot;yyyy-MM-dd&quot;</span><span style=\"font-size:13px\">))<br>\r\nResponse.Clear()<br>\r\nResponse.ContentType = </span><span style=\"font-size:13px;color:#a31515\">&quot;application/zip&quot;<br>\r\n</span><span style=\"font-size:13px\">Response.AddHeader(</span><span style=\"font-size:13px;color:#a31515\">&quot;content-disposition&quot;</span><span style=\"font-size:13px\">, </span><span style=\"font-size:13px;color:#a31515\">&quot;filename=&quot;</span><span style=\"font-size:13px\"> + archiveName)<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\"><br>\r\nDim</span><span style=\"font-size:13px\"> zip </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">New</span><span style=\"font-size:13px\"> ZipFile<br>\r\nzip.AddFileFromString(</span><span style=\"font-size:13px;color:#a31515\">&quot;Readme.txt&quot;</span><span style=\"font-size:13px\">, </span><span style=\"font-size:13px;color:#a31515\">&quot;&quot;</span><span style=\"font-size:13px\">, str.ToString())<br>\r\nzip.Save(Response.OutputStream)<br>\r\nResponse.End()<br>\r\n<br>\r\nThis code create one zip file, but when i try open this file with WinZip or WinRar, show me this message &quot;Cannot open file: it does not appear to be a valid archive&quot;.<br>\r\nI have WinZip 12.0 and WinRar 3.7<br>\r\nThe same with compressed files from Windows Explorer.<br>\r\n<br>\r\nCan you help me?</span></p>\r\n<p><span style=\"font-size:13px\">Thank you<br>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n",
    "PostedDate": "2009-04-24T07:34:12.823-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "184616",
    "ThreadId": "54375",
    "Html": "<p>Why are you not using a Using clause?  <br>\r\nThe using clause around the ZipFile is essential. <br>\r\n<br>\r\nI delivered an example, very similar to the code you posted.  <a href=\"http://code.msdn.microsoft.com/DotNetZip/Release/ProjectReleases.aspx?ReleaseId=2015\">http://code.msdn.microsoft.com/DotNetZip/Release/ProjectReleases.aspx?ReleaseId=2015</a>  Maybe you used the example as a starting point?    But the example I wrote employed a Using clause, whereas it is missing from your code. <br>\r\n<br>\r\nThe using clause closes the stream, releases resources.  Try it with the using clause and let me know. </p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2009-04-28T10:34:08.793-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "185865",
    "ThreadId": "54375",
    "Html": "<p>Thank you for your post.</p>\r\n<p>I change this (from original post code):</p>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n</span>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Dim</span><span style=\"font-size:13px\"> zip </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">New</span><span style=\"font-size:13px\"> ZipFile<br>\r\nzip.AddFileFromString(</span><span style=\"font-size:13px;color:#a31515\">&quot;Readme.txt&quot;</span><span style=\"font-size:13px\">, </span><span style=\"font-size:13px;color:#a31515\">&quot;&quot;</span><span style=\"font-size:13px\">, str.ToString())<br>\r\nzip.Save(Response.OutputStream)<br>\r\n<br>\r\n<br>\r\nfor this:<br>\r\n<p>&nbsp;</p>\r\n<p><span style=\"font-size:13px;color:#0000ff\">Using</span><span style=\"font-size:13px\"> zip </span><span style=\"font-size:13px;color:#0000ff\">As</span><span style=\"font-size:13px\"> ZipFile = </span><span style=\"font-size:13px;color:#0000ff\">New</span><span style=\"font-size:13px\"> ZipFile<br>\r\n</span><span style=\"font-size:13px\">    zip.AddFileFromString(</span><span style=\"font-size:13px;color:#a31515\">&quot;Readme.txt&quot;</span><span style=\"font-size:13px\">, </span><span style=\"font-size:13px;color:#a31515\">&quot;&quot;</span><span style=\"font-size:13px\">, str.ToString())<br>\r\n    zip.Save(Response.OutputStream)<br>\r\n</span><span style=\"font-size:13px;color:#0000ff\">End</span><span style=\"font-size:13px\"> </span><span style=\"font-size:13px;color:#0000ff\">Using</span><br>\r\n<br>\r\n<span style=\"font-size:13px\">from your suggestion example, but, i get the same  results.<br>\r\n<br>\r\n<br>\r\n<br>\r\n<br>\r\n</span><br>\r\n<span style=\"font-size:13px\">\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n</span></p>\r\n<p><span style=\"font-size:13px;color:#0000ff\"> \r\n<p>&nbsp;</p>\r\n</span></p>\r\n</span></p>\r\n",
    "PostedDate": "2009-05-01T05:47:44.283-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "185924",
    "ThreadId": "54375",
    "Html": "<p>CD, your code looks correct, and it should work. <br>\r\nI don't know what the problem might be but I can suggest a few things. </p>\r\n<ul>\r\n    <li>Try setting <span>Response.Expires = 1 </span>or some other non-zero number.  <a href=\"http://msdn.microsoft.com/en-us/library/system.web.httpresponse.expires.aspx\">doc for system.web.httpresponse.expires</a>\r\n    <p>There's <a href=\"http://stackoverflow.com/questions/774761/writing-out-a-zip-file-doesnt-work-in-ie7\">a report of a bug that exists in IE7</a> where a Response.Expires = 0 can lead to inability to save the downloaded file. I have not seen this myself. But it is worth checking. </p>\r\n    </li>\r\n    <li>There were a few problems in DotNetZip fixed since v1.7.2.12. They do not, on the surface, seem to be related to the problem you are experiencing. One problem that has been fixed had to do with creating an encrypted zip file in ASP.NET. Another problem now fixed, was that DotNetZip was failing to read some zip archives with comments of a particular form . These do not seem to be related to your issue, but it is worth getting on the latest DotNetZip to be sure. </li>\r\n</ul>\r\n<p>If those steps don't eliminate the problem, would it be possible for you to share the zip file in question that cannot be opened? You would have to open a workitem (via the tab across the top of this page labeled &quot;Issue Tracker&quot;), create a new workitem, and attach the failing zip file to the newly opened workitem. </p>\r\n",
    "PostedDate": "2009-05-01T09:17:39.403-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "185933",
    "ThreadId": "54375",
    "Html": "<div style=\"padding-right:0.6em;padding-left:0.6em;padding-bottom:0.6em;padding-top:0.6em\">I'm sorry Cheeso. <br>\r\nYou are right. Code is correct.<br>\r\nI finish discovering the error. I am using page compression with the MBCompression library. When i compression turn off, the zipfile generated is Ok. <br>\r\nI must investigate how to do that both libraries (Ionic and MBCompression) works together.<br>\r\n<br>\r\nThank you again<br>\r\n<br>\r\n</div>\r\n",
    "PostedDate": "2009-05-01T09:39:47.42-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "185940",
    "ThreadId": "54375",
    "Html": "My pleasure. I'm glad you found the source of the problem! <br>\r\n",
    "PostedDate": "2009-05-01T10:04:35.693-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]