c# - DotNetZip fails with "stream does not support seek operations" -



c# - DotNetZip fails with "stream does not support seek operations" -

i using dotnetzip in c# unzip stream follows:

public static void unzipfromstream(stream stream, string outdir) { //omit seek grab block using (zipfile zip = zipfile.read(stream)){ foreach (zipentry e in zip){ e.extract(outdir, extractexistingfileaction.overwritesilently); } } }

stream obtained using

webclient client = new webclient(); stream fs = client.openread(url);

however, got next exception

exception during extracting zip stream system.notsupportedexception: stream not back upwards seek operations. @ system.net.connectstream.get_position() @ ionic.zip.zipfile.read(stream zipstream, textwriter statusmessagewriter, encoding encoding, eventhandler`1 readprogress)

on server side(asp.net mvc 4), returning filepathresult or filestreamresult both caused exception.

should obtain stream differently on client side? or how create server homecoming "seekable" stream? thanks!

you'll have download info file or memory, , create filestream or memorystream, or other stream type supports seeking. example:

webclient client = new webclient(); client.downloadfile(url, filename); using (var fs = file.openread(filename)) { unzipfromstream(fs, outdir); } file.delete(filename);

or, if info fit memory:

byte[] info = client.downloaddata(url); using (var fs = new memorystream(data)) { unzipfromstream(fs, outdir); }

c# asp.net-mvc stream dotnetzip

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -