DotNetZip.Semverd icon indicating copy to clipboard operation
DotNetZip.Semverd copied to clipboard

Exception extracting from ZipEntry

Open lxman opened this issue 4 years ago • 1 comments

    private static MemoryStream GetClientFile(string file)
    {
        MemoryStream ms = new MemoryStream();
        using (ZipInputStream zip = new ZipInputStream(file))
        {
            ZipEntry ze = zip.GetNextEntry();
            while (!(ze is null))
            {
                if (ze.FileName.EndsWith("tag to locate entry"))
                {
                    ze.ExtractWithPassword(ms, "password");
                    return ms;
                }

                ze = zip.GetNextEntry();
            }
        }
        return ms;
    }

When I run this I get:

System.InvalidOperationException: Use Extract() only with ZipFile.

I get no intellisense errors, and per the docs, I think I should be able to do this.

lxman avatar Mar 23 '20 10:03 lxman

Hi, have you tried using ZipFile.Read(file) instead of ZipInputStream? Here's an example: https://github.com/haf/DotNetZip.Semverd/blob/f7e1c3547540bf43bc6819dac489e6b107b1c07a/src/Help/Code%20Examples/Csharp.htm#L279

darkms avatar Mar 24 '20 13:03 darkms