[
  {
    "Id": "263077",
    "ThreadId": "76950",
    "Html": "<p>Hi,</p>\r\n<p>I try to create a zip file with multiple documents in it. below is the code I use:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">Using</span> zip <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> ZipFile()\r\n      <span style=\"color:Green\">'TODO: handle same filename error</span>\r\n      <span style=\"color:Blue\">If</span> <span style=\"color:Blue\">Not</span> <span style=\"color:Blue\">String</span>.IsNullOrEmpty(dossierIdInvestplan) <span style=\"color:Blue\">Then</span>\r\n        <span style=\"color:Blue\">For</span> <span style=\"color:Blue\">Each</span> itemKoopsom <span style=\"color:Blue\">As</span> ListItem <span style=\"color:Blue\">In</span> cblDocumentsKoopsom.Items\r\n          <span style=\"color:Blue\">If</span> itemKoopsom.Selected <span style=\"color:Blue\">Then</span>\r\n            zip.AddEntry(itemKoopsom.Value &amp; <span style=\"color:#A31515\">&quot;.rtf&quot;</span>, <span style=\"color:#A31515\">&quot;&quot;</span>, GetUl3Document(dossierIdInvestplan, itemKoopsom.Value))\r\n          <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n        <span style=\"color:Blue\">Next</span>\r\n      <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n\r\n      <span style=\"color:Blue\">If</span> <span style=\"color:Blue\">Not</span> <span style=\"color:Blue\">String</span>.IsNullOrEmpty(dossierIdSaveplan) <span style=\"color:Blue\">Then</span>\r\n        <span style=\"color:Blue\">For</span> <span style=\"color:Blue\">Each</span> itemSpaarinspanning <span style=\"color:Blue\">As</span> ListItem <span style=\"color:Blue\">In</span> cblDocumentsSpaarinspanning.Items\r\n          <span style=\"color:Blue\">If</span> itemSpaarinspanning.Selected <span style=\"color:Blue\">Then</span>\r\n            zip.AddEntry(itemSpaarinspanning.Value &amp; <span style=\"color:#A31515\">&quot;.rtf&quot;</span>, <span style=\"color:#A31515\">&quot;&quot;</span>, GetUl3Document(dossierIdSaveplan, itemSpaarinspanning.Value))\r\n          <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n        <span style=\"color:Blue\">Next</span>\r\n      <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n\r\n      <span style=\"color:Blue\">Dim</span> archiveName <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span> = <span style=\"color:Blue\">String</span>.Format(<span style=\"color:#A31515\">&quot;archive-{0}.zip&quot;</span>, DateTime.Now.ToString(<span style=\"color:#A31515\">&quot;yyyy-MMM-dd-HHmmss&quot;</span>))\r\n\r\n      Response.Clear()\r\n      Response.BufferOutput = <span style=\"color:Blue\">False</span>\r\n      Response.ContentType = <span style=\"color:#A31515\">&quot;application/zip&quot;</span>\r\n      Response.AddHeader(<span style=\"color:#A31515\">&quot;content-disposition&quot;</span>, <span style=\"color:#A31515\">&quot;attachment; filename=&quot;</span> + archiveName)\r\n\r\n      <span style=\"color:Green\">'zip.Save(&quot;C:\\Documents and Settings\\A00428\\Desktop\\&quot; &amp; archiveName)</span>\r\n      zip.Save(Response.OutputStream)\r\n\r\n\r\n    <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n    HttpContext.Current.ApplicationInstance.CompleteRequest()<br></pre>\r\n</div>\r\n<p>GetUl3Document() returns a string which represents an rtf document. <br>When I use the overloaded Save function to save to a filesystem the zip is correctly saved, I can open it and the files are all intact and correct, so far so good...<br>However, when I use the Response.OutputStream Save function (Which is really the one I need) I get a save dialog, the zip gets saved but when I try to open it, it says the file is corrupt.<br>I don't really see anything wrong in my code but obviously something is. I already searched the forums but found nothing that helped so any help is greatly appreciated!</p>",
    "PostedDate": "2009-12-03T01:14:03.21-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "263290",
    "ThreadId": "76950",
    "Html": "<p>Your usage is probably correct.</p>\r\n<p>Try replacing&nbsp;</p>\r\n<pre>   HttpContext.Current.ApplicationInstance.CompleteRequest()\r\n</pre>\r\n<p>with&nbsp;</p>\r\n<pre>   Response.Close()\r\n</pre>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-03T09:51:37.95-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "263499",
    "ThreadId": "76950",
    "Html": "<p>Sweet! it works! Thank you very much!</p>",
    "PostedDate": "2009-12-03T23:07:02.6-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "263503",
    "ThreadId": "76950",
    "Html": "<p>Hey Dimitri - glad it works.&nbsp;&nbsp; Where did you get that code?&nbsp;&nbsp;&nbsp; Is there a sample that shows HttpContext.Current.ApplicationInstance.CompleteRequest()&nbsp;?&nbsp; &nbsp; I'd like to correct it if I can.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-03T23:21:27.58-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "263512",
    "ThreadId": "76950",
    "Html": "<p>I did not get that piece of&nbsp;code from a&nbsp;help file&nbsp;sample but I&nbsp;came across it&nbsp;a few times here on the forums.&nbsp;While testing I remember using Response.close once and it didn't work, but I probably had some other settings wrong at that time which resulted in a corrupt zip file. Thats why I changed it to something else.</p>",
    "PostedDate": "2009-12-03T23:40:52.24-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]