Archived Forum Post

Index of archived forum posts

Question:

How to set a password to a zip file?

Jan 07 '15 at 14:52

Firstly I create a zip file, myzip:

CkZip objZip; objZip.UnlockComponent("some**code"); objZip.NewZip(myzip);

And put several files into it:

objZip.Appendfiles(file1, true); objZip.Appendfiles(file2, true); ...

Then put a password:

objZip.SetPassword(password); ...

So I get a zip file myzip. What I expected is that I need the password to open myzip. But now the thing is, the password is set on each file inside the zip, not the zip itself.

My question is how to add a password to the created zip file instead of each files inside the zip file?

Thanks very much for anybody who gives a clue!


Accepted Answer

Encrypting each file is the new secure way to do it. What it sounds like you are looking for is the old (it's not secure be aware) way. You use the PasswordProtect method for that.

public bool PasswordProtect {get; set; }
true if the Zip should be password-protected using older Zip 2.0 encryption, commonly referred to as "password-protection".