I understand your question, but I still have to say that the event should be raised. Can you please send me your code to support@rebex.net, I will diagnose it?
Here is my proof, that the PasswordRequired is raised even the Password is set to non-null but incorrect password:
Code:
using (ZipArchive zip = new ZipArchive(new MemoryStream()))
{
// add an encrypted file
zip.Password = "test3";
zip.AddFile(new MemoryStream(new byte[1]), "file.txt");
// set incorrect password
zip.Password = "test";
int idx = 0;
// register handler
zip.PasswordRequired += (s, e) =>
{
e.Password = "test" + idx;
Console.WriteLine("ZipArchive.Password: {0}, PasswordRequired.Password: {1}", zip.Password, e.Password);
idx++;
};
Console.WriteLine("MaxPasswordRetryCount: " + zip.Options.MaxPasswordRetryCount);
// extract file
zip["file.txt"].ExtractToArray();
}
Output:
MaxPasswordRetryCount: 5
ZipArchive.Password: test, PasswordRequired.Password: test0
ZipArchive.Password: test, PasswordRequired.Password: test1
ZipArchive.Password: test, PasswordRequired.Password: test2
ZipArchive.Password: test, PasswordRequired.Password: test3
Alternatively, instead of setting e.Password, you can set zip.Password. Result will be the same:
Code:
// register handler
zip.PasswordRequired += (s, e) =>
{
zip.Password = "test" + idx;
Console.WriteLine("ZipArchive.Password: {0}, PasswordRequired.Password: {1}", zip.Password, e.Password);
idx++;
};
Output:
MaxPasswordRetryCount: 5
ZipArchive.Password: test0, PasswordRequired.Password:
ZipArchive.Password: test1, PasswordRequired.Password:
ZipArchive.Password: test2, PasswordRequired.Password:
ZipArchive.Password: test3, PasswordRequired.Password: