how to know an archive is password protected?

Apr 6, 2011 at 5:28 AM

Hi,

 I would like to know that whether an archive is protected by password, if yes, I can ask the user to enter the password then continue to extract the archive.

Nov 2, 2011 at 7:30 PM

 

just declare the extractor with no password for test and check the extractor before extract the archive like following code

fileExtractor = new SevenZipExtractor(archivePath);

if (fileExtractor.Check())
{
   fileExtractor.BeginExtractArchive(destination_dir);
}

doing this way the fileExtractor.Check() will be false when the archive require the password
but if declare the extractor with password and check like following code

fileExtractor = new SevenZipExtractor(archivePath, password);

if (fileExtractor.Check())
{
   fileExtractor.BeginExtractArchive(destination_dir);
}
if the password is not correct the fileExtractor.Check() will be false