mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
Excel files corrupted after extraction in password protected RAR file #374
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Mohammadhamza43 on GitHub (Sep 14, 2019).
I want to extract the password protected .rar file but when i extracted the .rar file the folder containing the excel file extracted but all the files in there are corrupted. It works fine when i extract non-password protected file.
Directory Structure:
example.rar --> example --> book1.xlsx
This is what i m doing:
using (var archive = RarArchive.Open(@"C:\Users\User\Desktop\example.rar", new SharpCompress.Readers.ReaderOptions() {
Password = "12345678"
}))
{
foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory))
{
entry.WriteToDirectory("D:\temp1", new ExtractionOptions()
{
ExtractFullPath = true,
Overwrite = true,
});
}
}
@adamhathcock commented on GitHub (Sep 14, 2019):
Probably is the wrong password. The only way to detect wrong passwords is with CRC if I recall correctly.
@Mohammadhamza43 commented on GitHub (Sep 17, 2019):
extracting a file with wrong password is possible? Working fine when i m extracting the same file using command line
@adamhathcock commented on GitHub (Sep 17, 2019):
What are you saying? WinRAR itself will extract the file with the correct password?
Incorrect password will extract garbage as there’s no way to detect if the password is correct without doing a CRC of the file.
@Mohammadhamza43 commented on GitHub (Sep 18, 2019):
what i m saying is that when i extract the same file manually using winrar with the same password it works fine. but with the above code its giving me garbage
@adamhathcock commented on GitHub (Sep 18, 2019):
I'm not sure what to tell you unless you can speak more of the encryption options and how they're different from the tests in the repo