Cannot open ZipFile via HttpWebRequest.

Apr 16, 2014 at 11:46 AM
I wrote the following method.
 public static ZipFile OpenFile(Uri zipFileToRead, string password = null)
        {
            var sw = Stopwatch.StartNew();

            ZipFile zip = null;
            if (zipFileToRead.Scheme == Uri.UriSchemeHttp)
            {

                var myReq = (HttpWebRequest)WebRequest.Create(zipFileToRead);
                WebResponse myResp = myReq.GetResponse();

                Stream stream = myResp.GetResponseStream();
                zip = ZipFile.Read(stream);

            }
            else
            {
                zip = ZipFile.Read(zipFileToRead.OriginalString);
              
            }

            if (password != null)
            {
                zip.Password = password;
            }
            Trace.WriteLine("Opening the Zip File took: " + sw.ElapsedMilliseconds + " ms");
            return zip;


        }
When my zip file is on a Webserver I get an error at the line "zip = ZipFile.Read(stream);" .

"This stream does not support seek operations".

Is it possible to open a Zip file on a Webserver for read operations? Thank you for help in advance!