[
  {
    "Id": "604947",
    "ThreadId": "255727",
    "Html": "\r\n<p>able to zip files that are on my drive, neat and simple!</p>\r\n<p><br>\r\nBut my goal is asp.net VB web application where user clicks a button command, which runs a &quot;select&quot; query on MSSql table with 3 fields:<br>\r\n-uniqueID &nbsp;(integer)</p>\r\n<p>-DATfile (varbinary - each row is a small data file~14kB each)</p>\r\n<p>-catLabel (string)</p>\r\n<p><br>\r\nI am new to asp.net, but I think I am stuck getting files to the arraylist. &nbsp;In examples you often use the variable: filesToInclude for the arraylist.</p>\r\n<p><br>\r\nany snippet or help to get files from the database to that variable would be appreciated!!!</p>\r\n<p><br>\r\n(typically about 10 to 30 files need to zipped &amp; downloaded at a time)<br>\r\nthanks</p>\r\n",
    "PostedDate": "2011-04-29T09:58:30.907-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "608956",
    "ThreadId": "255727",
    "Html": "<p>The DATfile column holds the bytes that make up the file to be included into the zip, is that right?</p>\r\n<p>I'm not a database expert, so I don't know how precisely to do this, but....&nbsp; What you need to do is get a readable stream from that DATfile column; that will make it easy to&nbsp;embed into a zipfile.</p>\r\n<div style=\"color: black; background-color: white;\">\r\n<pre><span style=\"color: blue;\">var</span> c1= <span style=\"color: blue;\">new</span> System.Data.SqlClient.SqlConnection(connstring1);\r\n<span style=\"color: blue;\">var</span> cmd=  <span style=\"color: blue;\">new</span> System.Data.SqlClient.SqlCommand(strSelect, c1);\r\n\r\n<span style=\"color: blue;\">var</span> sqlReader = cmd.ExecuteReader();\r\n\r\n<span style=\"color: blue;\">using</span>(Ionic.Zip.ZipFile zip = <span style=\"color: blue;\">new</span> Ionic.Zip.ZipFile())\r\n{\r\n    <span style=\"color: blue;\">while</span> (reader.Read()) \r\n    {\r\n         zip.AddEntry(zipEntryName, (name,stream) =&gt; {\r\n             <span style=\"color: blue;\">byte</span>[] rawData = <span style=\"color: blue;\">new</span> <span style=\"color: blue;\">byte</span>[size];\r\n             reader.GetBytes(2,0,rawData,0,rawData.Length);\r\n             stream.Write(rawData,0,rawData.Length);\r\n         });\r\n   }\r\n    reader.Close();\r\n     zip.Save(Response.OutputStream);\r\n}\r\n</pre>\r\n</div>\r\n<p>The above uses <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/633c4280-51ca-cc82-b5b5-86bbe9b2e947.htm\">the ZipFile.AddEntry() method that accepts a WriteDelegate</a>. Check the documentation for more information on it.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2011-05-07T07:22:46.23-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]