public void UnzipTSWFiles(string sourceDirectory, string destinationDirectory, string password)
{
DefaultEncryptionSettings protectionSettings = new DefaultEncryptionSettings() { Password = password };
using (ZipArchive zipArchive = new ZipArchive(output, ZipArchiveMode.Read, true, null, null, protectionSettings))
{
foreach (ZipArchiveEntry entry in zipArchive.Entries)
{
using (Stream entryStream = entry.Open())
using (FileStream fileStream = File.OpenWrite(string.Format("{0}/{1}", targetDirectory, entry.FullName)))
{
entryStream.CopyTo(fileStream);
}
}
}
}
{
DefaultEncryptionSettings protectionSettings = new DefaultEncryptionSettings() { Password = password };
using (ZipArchive zipArchive = new ZipArchive(output, ZipArchiveMode.Read, true, null, null, protectionSettings))
{
foreach (ZipArchiveEntry entry in zipArchive.Entries)
{
using (Stream entryStream = entry.Open())
using (FileStream fileStream = File.OpenWrite(string.Format("{0}/{1}", targetDirectory, entry.FullName)))
{
entryStream.CopyTo(fileStream);
}
}
}
}
Hello,
I tested the extraction of a sample 7-Zip archive on my end and was able to reproduce an 'InvalidDataException: End of Central Directory record could not be found.' error. Can you please share with us whether or not this is similar to your scenario and also what exactly are you experiencing that is unusual?
Attaching a sample archive that reproduces this behavior would also prove very helpful in resolving this case, so if you can please share one with us. I can assure you that anything shared by our clients is treated with strict confidentiality and is used for testing purposes only (as per our EULA section 11).
Thank you in advance for your cooperation.
Regards,
Yoan
{Telerik.Zip.InvalidDataException: End of central directory not found.
at Telerik.Zip.ZipArchive.ReadEndOfCentralDirectory() at Telerik.Zip.ZipArchive.Init(Stream stream, ZipArchiveMode mode, Boolean leaveOpen) at Telerik.Zip.ZipArchive..ctor(Stream stream, ZipArchiveMode mode, Boolean leaveOpen, Encoding entryNameEncoding, CompressionSettings compressionSettings, EncryptionSettings encryptionSettings) at CrownDownloadTool.ViewModels.SimpleMainViewModel.UnzipTSWFiles(String sourceDirectory, String destinationDirectory, String password)
Hello,
Seems like you have hit a known issue with 7-Zip files and missing end of file record. Please find more information in the public feedback item - ZipLibrary: Import archives without end of central directory record.
Regards,
Peshito
Hello,
Then how can we extract the 7Z's zip files using telerik Zip Library ,If not Possible is there any alternative solution.
Regards,
Purushotham Gowthu
Hello,
Even though this is mandatory by the specification some applications do not require it. I am afraid that there is no workaround that could be used. You can subscribe and vote to the feature request to increase its priority and also to get notified when its implementation is done.
Regards,
Peshito