[
  {
    "Id": "254050",
    "ThreadId": "74268",
    "Html": "<p>Using DotNetZip library in my vb.net application, I was able to zip a folder but&nbsp;unable to download. I know there is something missing here but I cannot figure out what. any feedback would be greatly appreciated.</p>\r\n<p>&nbsp;</p>\r\n<p>Private Sub ZipFolder(ByVal FolderToZip As String)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Clear()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.BufferOutput = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.Events.Write(&quot;we are here 1&quot;)</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim archiveName As String = String.Format(FolderToZip &amp; &quot;.zip&quot;, DateTime.Now.ToString(&quot;yyyy-MMM-dd-HHmmss&quot;))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.Events.Write(&quot;archiveName = &quot; &amp; archiveName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.ContentType = &quot;application/zip&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.AddHeader(&quot;content-disposition&quot;, &quot;filename=&quot; + archiveName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.Events.Write(&quot;we are here 2&quot;)</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using zip As ZipFile = New ZipFile()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.AddDirectory(FolderToZip)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.Save(FolderToZip &amp; &quot;.zip&quot;)</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.Save(Response.OutputStream)</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.Dispose()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Send the output to the client.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Response.Flush()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.Events.Write(&quot;we are here 3&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Using<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpContext.Current.ApplicationInstance.CompleteRequest()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Response.Close()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.Events.Write(&quot;we are here 4&quot;)<br>&nbsp;&nbsp;&nbsp; End Sub</p>",
    "PostedDate": "2009-11-05T18:29:29.127-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254101",
    "ThreadId": "74268",
    "Html": "<p>Seems like you are saving it twice?&nbsp; Any reason why?&nbsp;</p>\r\n<p>I don't know what app.Events.Write() does, but if it is writing to the outputstream, it will cause your download to fail.</p>\r\n<p>What is the error you are getting, anyway?</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">Private</span> <span style=\"color:Blue\">Sub</span> ZipFolder(<span style=\"color:Blue\">ByVal</span> FolderToZip <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span>)\r\n        Response.Clear()\r\n        Response.BufferOutput = <span style=\"color:Blue\">False</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(FolderToZip &amp; <span style=\"color:#A31515\">&quot;.zip&quot;</span>, DateTime.Now.ToString(<span style=\"color:#A31515\">&quot;yyyy-MMM-dd-HHmmss&quot;</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;filename=&quot;</span> + archiveName)\r\n\r\n        <span style=\"color:Blue\">Using</span> zip <span style=\"color:Blue\">As</span> ZipFile = <span style=\"color:Blue\">New</span> ZipFile()\r\n            zip.AddDirectory(FolderToZip)\r\n            zip.Save(Response.OutputStream)\r\n        <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Using</span>\r\n        Response.Close()\r\n<span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Sub</span>\r\n\r\n</pre>\r\n</div>",
    "PostedDate": "2009-11-05T22:00:09.683-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254119",
    "ThreadId": "74268",
    "Html": "<p>thanks for the reply.</p>\r\n<p>the app.Events.Write() is just my debugging code - it doesn't effect anything</p>\r\n<p>I am able to download now but zip.Save(Response.OutputStream) reveals the whole path to the client which is not a very good practice. any suggestion how to remedy this?</p>\r\n<p>thanks again.</p>",
    "PostedDate": "2009-11-05T23:41:42.66-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254142",
    "ThreadId": "74268",
    "Html": "<p>Yes - set the archiveName this way. (replace the code you have in your method)</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Green\">'' get a name for the archive</span>\r\n<span style=\"color:Green\">'' example output: Documents-2009-Nov-06-114211.zip</span>\r\n<span style=\"color:Blue\">Dim</span> archiveName <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span> = _\r\n    Path.GetFileName(FolderToZip) &amp; _\r\n    DateTime.Now.ToString(<span style=\"color:#A31515\">&quot;yyyy-MMM-dd-HHmmss&quot;</span>)) &amp; _\r\n    <span style=\"color:#A31515\">&quot;.zip&quot;</span>\r\n\r\n\r\n</pre>\r\n</div>\r\n<p>ps: What does the debugging code <em>do </em>?&nbsp;&nbsp; If it emits messages into the response outputstream, then it will corrupt the zip file.&nbsp; If, for example, you use it to update a Web control, enabling these diagnostic messages might cause the zip to break.&nbsp; Like &quot;The Observer effect.&quot;</p>",
    "PostedDate": "2009-11-06T00:57:36.96-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254241",
    "ThreadId": "74268",
    "Html": "<p>The code you mentioned above does not hide the full path. So&nbsp;i am still having trouble with this.&nbsp;</p>\r\n<p>the app.event.write writes to an event log - it's just a print statment, that's all. I can not by any means have the &quot;The Observer effect&quot;</p>\r\n<p>thanks again and looking forward to your reply</p>",
    "PostedDate": "2009-11-06T06:30:31.68-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254248",
    "ThreadId": "74268",
    "Html": "<p>My humble aplogy - it actualy worked and the path is not revealed any more. thank you so much.</p>\r\n<p>On another note, in another part of my application, I have embeded flash&nbsp;that lets the user selecet&nbsp;a whole bunch of files. Then I have to be able to zip these files&nbsp;in a folder and allow the user to download.&nbsp;The problem is that&nbsp;<span style=\"font-size:x-small\">zip.Save(Response.OutputStream) does not get a chance when flash is involved - and I think that's&nbsp;because Flash is trying to respond as well. Have you ever dealth with Flash and zip download? Do you know of any known issue?</span></p>\r\n<p><span style=\"font-size:x-small\">thanks again.</span></p>",
    "PostedDate": "2009-11-06T06:52:12.227-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "254297",
    "ThreadId": "74268",
    "Html": "<p>Ahh, I don't know much about Flash.&nbsp; and I don't know what you mean by &quot;zip.Save(Response.OutputStream) does not get a chance when flash is involved.&quot;&nbsp;</p>\r\n<p>I think you might be able to solve your problem by:</p>\r\n<ul>\r\n<li>saving the zip to a temporary location on the server filesystem</li>\r\n<li>providing a clickable link to the user, or maybe setting up an onClick handler in Flash (I don't know how that would work) </li>\r\n<li>sending the file to the user after the click event in flash.&nbsp; LIke I said, I don't know how to do a download in flash, but I would guess there.s a way. </li>\r\n<li>removing the zip file from the server filesystem after it is downloaded, or after some time passes</li>\r\n</ul>\r\n<p>Good luck!</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-11-06T08:52:40.033-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]