Setting password to a zip file
Hi,
I have an existing zip file. I would like to set a password to my existing zip file. I know how to zip, unzip using SharpZipLib. I am wondering, Is there a way to set a password without extracting and re-creating the zip file with password?
Let me know.
Thanks
Re: Setting password to a zip file
I am not sure but it this what you are looking for?
Re: Setting password to a zip file
I know that already. As i said in my OP, i know how to extract and rezip the files with password. What i am looking for is, is there anyway to set the password for existing zip file without extracting it?
Re: Setting password to a zip file
I thought but cannot test it may work by modifying the sample code in the link like this.
Code:
using ICSharpCode.SharpZipLib.Zip;
public void UpdateExistingZip() {
ZipFile zipFile = new ZipFile(@"c:\temp\existing.zip");
// Must call BeginUpdate to start, and CommitUpdate at the end.
zipFile.BeginUpdate();
zipFile.Password = "whatever"; // Only if a password is wanted on the new entry
// Both CommitUpdate and Close must be called.
zipFile.CommitUpdate();
zipFile.Close();
}