1

I have a zip file as an embedded resource. Using the following code:

Stream zipStream;
zipStream = thisAssembly.GetManifestResourceStream("Namespace.Resources.zipfile.zip");
byte[] data = Decompress(zipStream);

    public static byte[] Decompress(Stream zipStream)
            {
                ZipInputStream zipInputStream = new ZipInputStream(zipStream);
                //zipInputStream.CanDecompressEntry is false
                ZipEntry zipEntry;
                MemoryStream zipoutStream = new MemoryStream();

                while((zipEntry = zipInputStream.GetNextEntry()) != null)
                {
                    byte[] buffer = new byte[zipInputStream.Length];
                    zipInputStream.Read(buffer, 0, (int)zipInputStream.Length);
                    zipoutStream.Read(buffer, 0, buffer.Length);
                }
                return zipoutStream.ToArray();
            }

The decompress method always returns null. CanDecompressEntry is always false. Any other way to unzip embedded resources?

A G
  • 21,087
  • 11
  • 87
  • 112

1 Answers1

1

Maybe the problem is in "zipoutStream.Read" instead of "zipoutStream.Write"?

Alex Shtoff
  • 2,520
  • 1
  • 25
  • 53