Unable to password protect my zipped files

Nov 13, 2009 at 1:17 PM

Hi there,

I have followed the sample code to zip 2 text files to a particular location, but I have not been able to password protect it.  Please see my code below, and let me know what I have done wrong.

private void button1_Click(object sender, EventArgs e)
        {
               String[] filenames = {"C:\\Documents and Settings\\Nerisha.Bhajun-Visse\\My Documents\\Test1.txt",
                                        "C:\\Documents and Settings\\Nerisha.Bhajun-Visse\\My Documents\\Test2.txt"};
               using (ZipFile zip = new ZipFile())
                {
                    zip.Password = "123456";
                    zip.AddFiles(filenames,"zipped");
                    zip.Save("MyFile2.zip");
                    MessageBox.Show("File zipped!");

                }
       
        }

 

Coordinator
Nov 13, 2009 at 3:46 PM

Hello Nerisha,

Your code looks fine.  How are you able to tell that the entries in the resulting zip file are not password-protected?