I'm trying to unzip a nested zip file, but I'm getting a InvalidDataException. When I try unzipping the same file in Windows Explorer, it unzips successfully. Why would Windows Explorer be able to unzip it and not the .NET Core Compression library?
I suspect there is something wrong with the zip file, but if Windows Explorer is able to do it, it must be possible to do in a .NET Core project.
I've tried unzipping the parent zip file, but that throws the InvalidDataException 'A local file header is corrupt.'
ZipFile.ExtractToDirectory("parent.zip", outputFolder) // throws exception
I've tried opening the parent zip file and unzipping the nested zip file, but that also throws the InvalidDataException 'End of Central Directory record could not be found.'
using (var archive = ZipFile.OpenRead("parent.zip"))
{
var nestedZip = archive.GetEntry("nested.zip");
using (var stream = nestedZip.Open())
using (var nestedArchive = new Archive(stream)) // throws exception
{
nestedArchive.ExtractToDirectory(outputFolder)
}
}
Try the scenario with a different zip file and see if that works, if it works means that there's some issue with the zip file.
Also try using a different librairy.