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

Free Support Forum - aspose.com

Error extracting zip from a zip

There is some sample code in an aspose blog that shows how to extract a zip from a zip file but it throws an error when I try to run in on a zip file I have that contains two other zip files. The zip file opens fine in WinZip pro, but from the sample code it throws the error:

System.IO.InvalidDataException
HResult=0x80131501
Message=Signature of end of central directory does not match. Make sure the source is valid zip archive.
Source=Aspose.Zip

The code from the blog throws an error on the line using (var nestedArchive = new Archive(nestedArchiveStream))

The code in the blog is:

// Open ZIP file in a file stream
using (FileStream zipFile = File.Open(“Archives/nested-archive.zip”, FileMode.Open))
{
// Load ZIP file using Archive class
using (Archive archive = new Archive(zipFile, new ArchiveLoadOptions()))
{
// Access each entry in ZIP archive
foreach(ArchiveEntry entry in archive.Entries)
{
if(entry.Name.ToLower().Contains(".zip"))
{
// Create memory stream for nested archive
MemoryStream nestedArchiveStream = new MemoryStream();

            // Copy archive to memory stream
            entry.Open().CopyTo(nestedArchiveStream);

            // Load the nested archive from memory stream
            using (var nestedArchive = new Archive(nestedArchiveStream))
            {
                // Extract archive to disk.
                nestedArchive.ExtractToDirectory("Archives/Extracted/"+entry.Name);
            }                               

        }

    } 
}

}

Hello @TerryCarr,
Are sure that file is zip archive, not other archive format that WinZip supports?
Could you provide us with that file to review?

ErrorOnUnzip.zip (5.0 MB)

I just figured it out. Once I applied the temporary license, it extracted the whole zip file