To create password-protected zip files, set the Password property to a non-empty string before creating any entries. Each entry may have its own password. For example:
C# |
Copy Code
|
---|---|
C1ZipFile zip = new C1ZipFile(); zip.Password = "password"; zip.Entries.Add(someFile); |
To extract this entry later, the Password property must be set to the same value in effect when the entry was added. For example:
C# |
Copy Code
|
---|---|
// Will fail, password not set. C1Zip.Password = ""; C1Zip.Entries.Extract(someFile); // Will fail, wrong password. C1Zip.Password = "pass"; C1Zip.Entries.Extract(someFile); // Will succeed. C1Zip.Password = "password"; C1Zip.Entries.Extract(someFile); |