[
  {
    "Id": "161162",
    "ThreadId": "48295",
    "Html": "I need to open an existing archive, add a file (without altering the original saved archive) and insert the whole thing into the output stream for download. The following code will get the job done but with a poor user experience. <br>\r\n<br>\r\nResponse.Clear();<br>\r\nResponse.ContentType = &quot;application/zip&quot;;<br>\r\nResponse.AddHeader(&quot;content-disposition&quot;, &quot;filename=&quot; + _FileName);<br>\r\nResponse.AppendHeader(&quot;Content-Encoding&quot;, &quot;application/x-zip-compressed&quot;);<br>\r\nResponse.BufferOutput = false;<br>\r\n<br>\r\n// create a new zip and insert into output stream<br>\r\nusing (ZipFile zip = new ZipFile(Response.OutputStream))<br>\r\n{<br>\r\n&nbsp;&nbsp;&nbsp; // add the original zip file requested<br>\r\n&nbsp;&nbsp;&nbsp; zip.AddFile(Server.MapPath(_FilePath + _FileName));<br>\r\n&nbsp;&nbsp; &nbsp;<br>\r\n&nbsp;&nbsp;&nbsp; // add readme file<br>\r\n&nbsp;&nbsp;&nbsp; zip.AddFile(Server.MapPath(_FilePath + &quot;ReadMe.txt&quot;));<br>\r\n&nbsp;&nbsp; &nbsp;<br>\r\n&nbsp;&nbsp;&nbsp; zip.Save();<br>\r\n&nbsp;&nbsp;&nbsp; zip.Dispose();<br>\r\n&nbsp;&nbsp;&nbsp; Response.End();<br>\r\n}<br>\r\n<br>\r\nThe result is a zip file that contains both the original requested\r\ndownload zip + the new file, so the user has to unzip an archive that\r\ncontains yet another zipped archive containing the files they\r\noriginally requested.<br>\r\n<br>\r\nIs it possible to simply open an archive and insert that into the filestream, rather than creating a new archive directly into the filestream?&nbsp; I found a post on another forum that indicated that the following code should work, but it does not -- the Save() method will not allow Response.OutputStream as a valid parameter.<br>\r\n<br>\r\n// open existing saved zip file<br>\r\nusing (ZipFile zip = ZipFile.Read(Server.MapPath(_FilePath + _FileName)))<br>\r\n{<br>\r\n&nbsp;&nbsp;&nbsp; // add readme file<br>\r\n&nbsp;&nbsp;&nbsp; zip.AddFile(Server.MapPath(_FilePath + &quot;ReadMe.txt&quot;));<br>\r\n&nbsp;&nbsp; &nbsp;<br>\r\n&nbsp;&nbsp; &nbsp;// insert into output stream<br>\r\n&nbsp;&nbsp;&nbsp; zip.Save(Response.OutputStream);<br>\r\n&nbsp;&nbsp;&nbsp; zip.Dispose();<br>\r\n&nbsp;&nbsp;&nbsp; Response.End();<br>\r\n}<br>\r\n<br>\r\nPlease help. Thanks!<br>\r\n",
    "PostedDate": "2009-02-23T15:00:36.253-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "161192",
    "ThreadId": "48295",
    "Html": "&quot;the Save method will not allow....&quot; <br>\r\n<br>\r\nWhy won't it allow that? What is the error you are getting?  a compile-time error or a Runtime exception? <br>\r\nmore info please?<br>\r\nI believe what you are trying <em>should work</em>. <br>\r\n",
    "PostedDate": "2009-02-23T16:23:11.583-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "161195",
    "ThreadId": "48295",
    "Html": "Thanks, Cheeso. The error I'm getting is compile-time:<br>\r\n<br>\r\nThe best overloaded method match for 'Ionic.Utils.Zip.ZipFile.Save(string)' has some invalid arguments<br>\r\nArgument '1': cannot convert from 'System.IO.Stream' to 'string'<br>\r\n<br>\r\nThe Save() method seems to only want a string.<br>\r\n<br>\r\n",
    "PostedDate": "2009-02-23T16:28:45.167-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "161198",
    "ThreadId": "48295",
    "Html": "Ah.<br>\r\nWhat version of DotNetZip are you using?  In v1.6, there was no overload of the Save() method that accepted a Stream.  This was added in v1.7, which is the latest stable version. <br>\r\nYou can download it from the releases tab.\r\n",
    "PostedDate": "2009-02-23T16:41:23.423-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "161208",
    "ThreadId": "48295",
    "Html": "Thanks, Cheeso! I downloaded 1.7 and now it works perfectly.<br>\r\n",
    "PostedDate": "2009-02-23T17:10:43.643-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "161219",
    "ThreadId": "48295",
    "Html": "Super!  That was easy.\r\n",
    "PostedDate": "2009-02-23T18:19:53.993-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]