We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems opening contained archive files

I have a pretty basic ZIP file, that contains two other ZIPs and a 7z file. All 4 ZIP files work fine when loading directly from the filesystem. But when those 3 are inside another ZIP, I get the below errors trying to load the 7z and one of the ZIPs the way the example code shows. The other embedded ZIP works.

7z file fails with:

  • Index was outside the bounds of the array.
    ZIP file fails with:
  • Signature of end of central directory does not match. Make sure the source is valid zip archive.

I can provide a sample file.

Hello @craigx, please provide us with the piece of code as well.

Here is the code, basically a copy from the example code:

        using (Archive archive = new Archive(@"Files.zip"))
        {
            foreach (ArchiveEntry entry in archive.Entries)
            {
                if (entry.Name.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase))
                {
                    MemoryStream memStream = new MemoryStream();
                    entry.Open().CopyTo(memStream);

                    try
                    {
                        Archive innerArchive = new Archive(memStream);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(entry.Name + ": " + ex.Message);
                    }
                }
                else if (entry.Name.EndsWith(".7z", StringComparison.InvariantCultureIgnoreCase))
                {
                    MemoryStream memStream = new MemoryStream();
                    entry.Open().CopyTo(memStream);

                    try
                    {
                        SevenZipArchive innerArchive = new SevenZipArchive(memStream);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(entry.Name + ": " + ex.Message);
                    }
                }
            }
        }

Files.zip (9.0 MB)

Thank you, we’ll review and let you know.

Hello @craigx, please seek memory stream to beginning before decompressing from it: memStream.Seek(0, SeekOrigin.Begin);