[
  {
    "Id": "262905",
    "ThreadId": "76897",
    "Html": "<p>Hello there</p>\r\n<p>&nbsp;</p>\r\n<p>This is what I am trying to do:</p>\r\n<p>I have a WCF service, which I want to transfer a huge file to the client. It uses ChunkingChannel and Streaming to do that:</p>\r\n<p>&nbsp;</p>\r\n<p>[OperationContract]</p>\r\n<p>public Stream DownloadLargeFile();</p>\r\n<p>&nbsp;</p>\r\n<p>(I do not have the code at hand, since I am at home at the moment).</p>\r\n<p>The method opens a ZIP-File via FileStream, and returns that FileStream. That's what happens server-side.</p>\r\n<p>&nbsp;</p>\r\n<p>Client-side I want to open that stream via the ZipFile()-constructor (I found in the examples that it can take a stream as parameter), and extract all files to the client harddisk.</p>\r\n<p>&nbsp;</p>\r\n<p>What happens now is that it throws an NotSupportedException. Seems that the Stream-class does not have the Peek() method implemeted. I have seen that DotNetZip had a quite similar problem some time ago in issue #7742. This has been related to AddFileFromStream() and has been fixed.</p>\r\n<p>&nbsp;</p>\r\n<p>Maybe you could help me with this issue? If you need more code, callstack or the whole exeption, I can provide you with those information in the morning.</p>",
    "PostedDate": "2009-12-02T12:34:30.063-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "262998",
    "ThreadId": "76897",
    "Html": "<p>Definitely would need to have the full exception to understand the nature of the problem.</p>\r\n<p>I haven't tried ZipFile.Read() on a forward-only stream.&nbsp;&nbsp; If you are telling me that it fails on a Seek() (not Peek) I can believe that.&nbsp;&nbsp; To solve that, if I were you I might try wrapping a <a href=\"http://msdn.microsoft.com/en-us/library/system.io.bufferedstream.aspx\">BufferedStream</a> around the stream you have - it may provide a Seek() where DotNetZip expects one.</p>\r\n<p>There is also an alternaive class, <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/a1a897db-bc65-2b08-875c-75fc3977b00f.htm\">ZipInputStream</a>, which is new for v1.9.&nbsp; It offers a read-forward stream model on a zip stream.&nbsp;&nbsp; If you can give up the random-access capability of ZipFile, ZipInputStream may be just the thing.&nbsp; Just to be clear, by &quot;Random access&quot;&nbsp; I mean, once you have a ZipFile instance, you can reference any ZipEntry by name or by numeric index, you can extract or remove them, and so on.&nbsp; All this stuff requires Seek() on the source stream.&nbsp; ZipInputStream&nbsp;reads forward only, so it may solve your problem, if you are willing to give up the random access.</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">private</span> <span style=\"color:Blue\">void</span> Unzip(Stream rawStream)\r\n{\r\n    <span style=\"color:Blue\">byte</span>[] buffer= <span style=\"color:Blue\">new</span> <span style=\"color:Blue\">byte</span>[2048];\r\n    <span style=\"color:Blue\">int</span> n;\r\n    <span style=\"color:Blue\">using</span> (<span style=\"color:Blue\">var</span> input= <span style=\"color:Blue\">new</span> ZipInputStream(rawStream))\r\n    {\r\n        ZipEntry e;\r\n        <span style=\"color:Blue\">while</span> (( e = input.GetNextEntry()) != <span style=\"color:Blue\">null</span>)\r\n        {\r\n            <span style=\"color:Green\">// Here you can decide whether to read/extract the current </span>\r\n            <span style=\"color:Green\">// entry.  Regardless, once you call GetNextEntry(), </span>\r\n            <span style=\"color:Green\">// you cannot return to the entry you've &quot;passed over&quot;. </span>\r\n            <span style=\"color:Blue\">if</span> (e.IsDirectory) <span style=\"color:Blue\">continue</span>;\r\n            <span style=\"color:Blue\">string</span> outputPath = Path.Combine(extractDir, e.FileName);\r\n            <span style=\"color:Blue\">using</span> (<span style=\"color:Blue\">var</span> output = File.Open(outputPath, FileMode.Create, FileAccess.ReadWrite))\r\n            {\r\n                <span style=\"color:Blue\">while</span> ((n= input.Read(buffer, 0, buffer.Length)) &gt; 0)\r\n                {\r\n                    output.Write(buffer,0,n);\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\n</pre>\r\n</div>\r\n<p>You need DotNetZip v1.9 to get the ZipInputStream.&nbsp;</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-12-02T18:15:01.2-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "263081",
    "ThreadId": "76897",
    "Html": "<p>Cheeno: Thanks for your fast reply, excellent support of an excellent project!</p>\r\n<p>Here is the full exception:</p>\r\n<p>&nbsp;</p>\r\n<p>\r\n<pre>System.NotSupportedException: Die angegebene Methode wird nicht unterst&uuml;tzt.\r\n   bei System.ServiceModel.Dispatcher.StreamFormatter.MessageBodyStream.Seek(Int\r\n64 offset, SeekOrigin origin)\r\n   bei Ionic.Zip.ZipEntry.HandlePK00Prefix(Stream s) in c:\\dinoch\\dev\\dotnet\\zip\r\n\\DotNetZip\\Zip Partial DLL\\ZipEntry.Read.cs:Zeile 392.\r\n   bei Ionic.Zip.ZipEntry.ReadEntry(ZipContainer zc, Boolean first) in c:\\dinoch\r\n\\dev\\dotnet\\zip\\DotNetZip\\Zip Partial DLL\\ZipEntry.Read.cs:Zeile 350.\r\n   bei Ionic.Zip.ZipFile.ReadIntoInstance_Orig(ZipFile zf) in c:\\dinoch\\dev\\dotn\r\net\\zip\\DotNetZip\\Zip Partial DLL\\ZipFile.Read.cs:Zeile 1207.\r\n   bei Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf) in c:\\dinoch\\dev\\dotnet\\zi\r\np\\DotNetZip\\Zip Partial DLL\\ZipFile.Read.cs:Zeile 1079.\r\n   bei Ionic.Zip.ZipFile.Read(Stream zipStream, TextWriter statusMessageWriter,\r\nEncoding encoding, EventHandler`1 readProgress) in c:\\dinoch\\dev\\dotnet\\zip\\DotN\r\netZip\\Zip Partial DLL\\ZipFile.Read.cs:Zeile 849.\r\n   bei Ionic.Zip.ZipFile.Read(Stream zipStream, TextWriter statusMessageWriter,\r\nEncoding encoding) in c:\\dinoch\\dev\\dotnet\\zip\\DotNetZip\\Zip Partial DLL\\ZipFile\r\n.Read.cs:Zeile 781.\r\n   bei Ionic.Zip.ZipFile.Read(Stream zipStream) in c:\\dinoch\\dev\\dotnet\\zip\\DotN\r\netZip\\Zip Partial DLL\\ZipFile.Read.cs:Zeile 504.\r\n   bei MovieFetcher.CMovieCheckerProcess.DownloadClientDataTest() in D:\\project\\\r\nbattleforge\\release\\beta\\tool\\ServerMovieAutomation\\MovieFetcher\\MovieFetcher.cs\r\n:Zeile 220.\r\n   bei MovieFetcher.CMovieCheckerProcess.ProcessMovieCallback(Object _oState) in\r\n D:\\project\\battleforge\\release\\beta\\tool\\ServerMovieAutomation\\MovieFetcher\\Mov\r\nieFetcher.cs:Zeile 234.\r\n   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext,\r\nContextCallback callback, Object state)\r\n   bei System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_Thr\r\neadPoolWaitCallback tpWaitCallBack)\r\n   bei System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state\r\n)\r\n</pre>\r\n</p>\r\n<p>I will have a look at ZipInputStream, I already saw that in 1.9 beta. In this case, I do only need to exctract all the files in the ZIP-file, so no need for random access. So this might be worth a try.</p>",
    "PostedDate": "2009-12-03T01:19:23.593-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]