[
  {
    "Id": "1108536",
    "ThreadId": "462524",
    "Html": "I posted this on stackoverflow but couldnt get a resolution.<br />\n<br />\nI am try to download a zip file via a url to extract files from. I would rather not have to save it a temp file (which works fine) and rather keep it in memory - it is not very big. For example, if I try to download this file:<br />\n<br />\n<a href=\"http://phs.googlecode.com/files/Download%20File%20Test.zip\" rel=\"nofollow\">http://phs.googlecode.com/files/Download%20File%20Test.zip</a><br />\n<br />\nusing this code:<br />\n<pre><code>using Ionic.Zip;\n...\nHttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);\nHttpWebResponse response = (HttpWebResponse)request.GetResponse();\n\nif (response.ContentLength &gt; 0)\n{\n    using (MemoryStream zipms = new MemoryStream())\n    {\n        int bytesRead;\n        byte[] buffer = new byte[32768];\n\n        using (Stream stream = response.GetResponseStream())\n        {\n            while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) &gt; 0)\n                zipms.Write(buffer, 0, bytesRead);\n\n            ZipFile zip = ZipFile.Read(stream); // &lt;--ERROR: &quot;This stream does not support seek operations. &quot;\n        }\n\n        using (ZipFile zip = ZipFile.Read(zipms)) // &lt;--ERROR: &quot;Could not read block - no data!  (position 0x00000000) &quot;\n        using (MemoryStream txtms = new MemoryStream())\n        {\n            ZipEntry csentry= zip[&quot;Download File Test.cs&quot;];\n            csentry.Extract(txtms);\n            txtms.Position = 0;\n            using (StreamReader reader = new StreamReader(txtms))\n            {\n                string csentry = reader.ReadToEnd();\n            }\n        }\n    }\n}</code></pre>\n\nNote where i flagged the errors I am receiving. With the first one, it does not like the System.Net.ConnectStream. If I comment that line out and allow it to hit the line where I note the second error, it does not like the MemoryStream. I did see this posting: <a href=\"http://stackoverflow.com/a/6377099/1324284\" rel=\"nofollow\">http://stackoverflow.com/a/6377099/1324284</a> but I am having the same issues that others mention about not having more then 4 overloads of the Read method so I cannot try the WebClient.<br />\n<br />\nHowever, if I do everything via a FileStream and save it to a temp location first, then point ZipFile.Read at that temp location, everything works including extracting any contained files into a MemoryStream.<br />\n<br />\nThanks for any help.<br />\nErnie<br />\n",
    "PostedDate": "2013-10-16T15:20:24.683-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]