How can I extract the files from a .rar archive protected by password, using SharpCompress?

1.2k views Asked by At

I want to extract the files from a given .rar archive, which is password protected. I have the following:

pwd = "password";
srs = @"c:\path\file.rar"
des = @"c:\path\folder"

using (var archive = RarArchive.Open(srs, new ReaderOptions() { Password = pwd }))
            {
                foreach (var entry in archive.Entries)
                {
                    entry.WriteToDirectory(des, new ExtractionOptions()
                    {
                        ExtractFullPath = true,
                        Overwrite = true
                    });
                }

but it extracts the files corrupted, both when the password is correct and incorrect.

0

There are 0 answers