1

I'm writing an window form similar to 7-Zip, my problem is in the extraction part, I don't know how to check if the archive I want to extract is password protected or not. Any idea?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
carryall
  • 482
  • 3
  • 10
  • 21

2 Answers2

1

I've got the solution: just check the extractor before extracting the archive:

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

Doing it this way the fileExtractor.Check() will be false, if the archive requires a password, and you're not providing the password for it or the password is not correct.

Thomas Freudenberg
  • 5,048
  • 1
  • 35
  • 44
carryall
  • 482
  • 3
  • 10
  • 21
0

It depends on the archive type. The ZIP specification describes how it's done for ZIP, although it's not very robust apparently.

John Weldon
  • 39,849
  • 11
  • 94
  • 127