[
  {
    "Id": "573924",
    "ThreadId": "248017",
    "Html": "\r\n<p>The following routine will read an ArrayList of Byte[] and load each entry into the zip file.<br>\r\nWhen I use zip.save(somefilename) it saves my zip file to my disk and looks perfect.</p>\r\n<p><br>\r\nBut, now I need to return a byte[] from this method which contains the zip file.</p>\r\n<p>How would I do this?</p>\r\n<p>Any help will be greatly appreciated.</p>\r\n<p>private byte[] GenerateMergedZipFile(ArrayList files, string[] byteInfo, string finalZipFormat, string ZipFileName)<br>\r\n{<br>\r\n&nbsp;byte[] result = null;</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n<br>\r\n&nbsp;using (ZipFile zip = new ZipFile())<br>\r\n&nbsp;{<br>\r\n&nbsp; int ctr = 0;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach (Byte[] inputFile in files)<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Add the stream into the zip entry.<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ZipEntry e = zip.AddEntry(byteInfo[ctr] &#43; &quot;.&quot; &#43; finalZipFormat, inputFile);<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ctr&#43;&#43;;<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>\r\n<p><br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Save the zip file.</p>\r\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; zip.Save ???<br>\r\n&nbsp;&nbsp;result =??<br>\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return result;<br>\r\n&nbsp; }<br>\r\n}</p>\r\n",
    "PostedDate": "2011-03-01T09:09:14.833-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "577722",
    "ThreadId": "248017",
    "Html": "<p>If what you want is an array of bytes containing the data for the zipfile, I suggest passing a MemoryStream to your call to ZipFile.Save(), and then calling the ToArray() method on the MemoryStream. There's no need to save the zipfile to a filesystem file.</p>\r\n<p>If you want BOTH a filesystem file and a byte array, then save to a filesystem file, and then read the data from the filesystem file using the appropriate method on the&nbsp;System.IO.File class.&nbsp; Or, you could do the converse - save to a MemoryStream, then write the data into the filesystem file using the appropriate method on the&nbsp;System.IO.File class.&nbsp;</p>\r\n<p>Good luck.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-03-09T06:10:14.693-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "577723",
    "ThreadId": "248017",
    "Html": "\r\n<div>\r\n<p><span style=\"font-size:11.0pt; font-family:\">Thanks for your response.</span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\"></span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\"></span></p>\r\n<p><span style=\"font-size:11.0pt; font-family:\"></span></p>\r\n<div>\r\n<div style=\"border:none; border-top:solid #B5C4DF 1.0pt; padding:3.0pt 0in 0in 0in\">\r\n<p><b><span style=\"font-size:10.0pt; font-family:\">From:</span></b><span style=\"font-size:10.0pt; font-family:\"> Cheeso [email removed]\r\n<br>\r\n<b>Sent:</b> Wednesday, March 09, 2011 9:10 AM<br>\r\n<b>To:</b> Chernick, Howie<br>\r\n<b>Subject:</b> Re: Returning a zip file as a Byte[] in C# ?? [DotNetZip:248017]</span></p>\r\n</div>\r\n</div>\r\n<p></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\">From: Cheeso</span></p>\r\n<div id=\"x_x_ThreadNotificationPostBody\" style=\"margin-bottom:24.0pt\">\r\n<p><span style=\"font-size:9.0pt; font-family:\">If what you want is an array of bytes containing the data for the zipfile, I suggest passing a MemoryStream to your call to ZipFile.Save(), and then calling the ToArray() method on the MemoryStream. There's no\r\n need to save the zipfile to a filesystem file.</span></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\">If you want BOTH a filesystem file and a byte array, then save to a filesystem file, and then read the data from the filesystem file using the appropriate method on the System.IO.File class. Or, you could do the\r\n converse - save to a MemoryStream, then write the data into the filesystem file using the appropriate method on the System.IO.File class.\r\n</span></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\">Good luck.</span></p>\r\n<p><span style=\"font-size:9.0pt; font-family:\"></span></p>\r\n</div>\r\n<pre><span style=\"font-size:11.5pt\"> </span></pre>\r\n<pre><span style=\"font-size:11.5pt\">--------------------------------------------------</span></pre>\r\n<pre><span style=\"font-size:11.5pt\">This e-mail and any files transmitted with it may contain privileged or confidential information.</span></pre>\r\n<pre><span style=\"font-size:11.5pt\">It is solely for use by the individual for whom it is intended, even if addressed incorrectly.</span></pre>\r\n<pre><span style=\"font-size:11.5pt\">If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute,</span></pre>\r\n<pre><span style=\"font-size:11.5pt\">or take any action in reliance on the contents of this information; and delete it from</span></pre>\r\n<pre><span style=\"font-size:11.5pt\">your system. Any other use of this e-mail is prohibited.</span></pre>\r\n<pre><span style=\"font-size:11.5pt\"> </span></pre>\r\n<pre><span style=\"font-size:11.5pt\">Thank you for your compliance.</span></pre>\r\n<pre><span style=\"font-size:11.5pt\">--------------------------------------------------</span></pre>\r\n</div>\r\n",
    "PostedDate": "2011-03-09T06:11:38.953-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]