[
  {
    "Id": "558313",
    "ThreadId": "244046",
    "Html": "\r\n<p>I'm trying to compress an entire directory using the AddDirectory method, however it will not apply a password to the file. &nbsp;Is there a way to do this or will I have to manually iterate through the directory and add each item individually?</p>\r\n",
    "PostedDate": "2011-01-31T13:50:18.083-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "558471",
    "ThreadId": "244046",
    "Html": "\r\n<p>Set the Password property on the ZipFile before calling ZipFile.AddDirectory().</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2011-01-31T21:29:27.477-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "558649",
    "ThreadId": "244046",
    "Html": "\r\n<p>I do set the password property prior to calling the AddDirectory method but I am still able to extract the resulting archive without entering a password.</p>\r\n",
    "PostedDate": "2011-02-01T05:52:54.23-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559374",
    "ThreadId": "244046",
    "Html": "\r\n<p>That would be a surprise. can you show me your code?&nbsp; Specifically, everything within the using() clause for the ZipFile.</p>\r\n",
    "PostedDate": "2011-02-02T06:42:40.053-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559390",
    "ThreadId": "244046",
    "Html": "\r\n<p>Using zip As New ZipFile &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>\r\n<span style=\"white-space:pre\"></span>zip.Password = &quot;123456&quot;<br>\r\n<span style=\"white-space:pre\"></span>zip.Encryption = EncryptionAlgorithm.WinZipAes256 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>\r\n<span style=\"white-space:pre\"></span>zip.AddDirectory(&quot;C:\\Temp&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>\r\n<span style=\"white-space:pre\"></span>zip.Save(&quot;C:\\Temp\\Test.zip&quot;) &nbsp; &nbsp; &nbsp; &nbsp;<br>\r\nEnd Using</p>\r\n<p>It's just a basic test. &nbsp;The directory and subdirectories compress correctly, but I can extract them using WinRar without entering a password.</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2011-02-02T07:01:26.11-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559618",
    "ThreadId": "244046",
    "Html": "\r\n<p>Just tested your code here. I don't see the results you report. I don't have WinRar, but I used Windows itself to open the zip file.</p>\r\n<p>When I open the file I can see the entries.&nbsp; This is expected and documented behavior.&nbsp;(See the information on the&nbsp;ZipFile.Password property) &nbsp;When I try to extract any entry, Windows tells me it cannot extract.&nbsp; (This is because\r\n Windows doesn't handle AES encryption in zip files).</p>\r\n<p>If I open the zip in the DotNetZip tool (&quot;\\Program Files (x86)\\Dino Chiesa\\DotNetZip Tools v1.9\\DotNetZip-WinFormsTool.exe&quot;) , once again I can see all the entries. When I try to extract the entries, the tool prompts me for the password, as expected.&nbsp;\r\n It cannot extract without the password.</p>\r\n<p>What version of the DotNetZip library are you using?&nbsp; Are you certain that you are\r\n<em>extracting </em>the files, and not just viewing the entry names and metadata?</p>\r\n",
    "PostedDate": "2011-02-02T11:19:24.143-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559628",
    "ThreadId": "244046",
    "Html": "\r\n<p>I can fully extract and use/open/rename/delete/etc the files contained within the zip file without entering a password using both WinRar and WinZip.&nbsp;</p>\r\n<p>I'm using&nbsp;DotNetZip&nbsp;Version 1.9.<br>\r\n<br>\r\n</p>\r\n",
    "PostedDate": "2011-02-02T11:34:23.947-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559629",
    "ThreadId": "244046",
    "Html": "\r\n<p>Even if I do not attempt to encrypt the archive, I am able to extract the directory and files contained within and use them without a password.</p>\r\n",
    "PostedDate": "2011-02-02T11:35:31.18-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559646",
    "ThreadId": "244046",
    "Html": "\r\n<p>I think there's an assumption you're making that isn't valid.</p>\r\n<p>Is it possible that the zipfile you are opening and extracting is NOT what you think it is?&nbsp; Is it possible you are opening and extracting a zipfile that was produced by an earlier version of your app that did not use encryption? or a zipfile that was\r\n produced by some other tool?</p>\r\n<p>Is it a possibility is that you are holding open the resulting zipfile, and when you run your app, it is silently throwing and suppressing&nbsp;an exception, with the result that \\temp\\test.zip is not getting updated?</p>\r\n<p>One thing I didn't point out in your code: you are saving to the file c:\\temp\\test.zip , and also implicitly including that c:\\temp\\test.zip into the final zip file. This seems&nbsp;like not something you want to do.&nbsp; If you run the app multiple times\r\n in succession, the size of the final zip file grows and grows.&nbsp;</p>\r\n<p>A way to test this further on your end would be to simplify your test app one more time - instead of using AddDirectory(), call AddFile().&nbsp; Create a zip file with a single entry in it.&nbsp;</p>\r\n<p>Use a new name for the final zip file (not \\temp\\test.zip) .&nbsp; then see if you can open that new file and extract the single entry.</p>\r\n<p>Somewhere along the chain there is an assumption that's been made, that is not valid.</p>\r\n<p>I have a test suite with hundreds of tests; some of them specifically focus on creating zip files with AES encryption and then verifying that it is impossible to extract entries from those zip files without supplying a password.&nbsp; So I'm pretty certain\r\n that AES encryption in DotNetZip&nbsp;works.&nbsp;</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2011-02-02T12:00:07.94-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559674",
    "ThreadId": "244046",
    "Html": "\r\n<p>Thanks for trying here but no it is not possible that I am opening and extracting a zip file produced by an earlier version or by a different tool. &nbsp;I am also not holding open the zip file when I run my app and suppressing an exception. &nbsp;<br>\r\n<br>\r\nThe code that I listed above is the exact code I'm running to test the password functionality.<br>\r\n<br>\r\nEven if I change the location of the resulting zip file the password functionality does not work. &nbsp;&nbsp;</p>\r\n<p>This is the exact test code I am running.<br>\r\nPrivate Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br>\r\n&nbsp;&nbsp; &nbsp; Using zip As New ZipFile&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>\r\n&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;zip.Password = &quot;123456&quot; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>\r\n&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;zip.AddDirectory(&quot;C:\\Temp&quot;) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>\r\n&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;zip.Save(&quot;C:\\Test\\Test.zip&quot;)&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br>\r\n&nbsp;&nbsp; &nbsp; End Using &nbsp; &nbsp;<br>\r\nEnd Sub<br>\r\n<br>\r\nThe password functionality will work if I add individual files; however, it does not work when using the AddDirectory method. &nbsp;Which will be required in the application I am going to build.</p>\r\n<p>I can't think of anything else that would cause a problem. &nbsp;The VB.Net application consists of a single form built solely to test DotNetZip. &nbsp;The only additional reference is to the Ionic.Zip dll.<br>\r\n<br>\r\n&nbsp;</p>\r\n",
    "PostedDate": "2011-02-02T12:50:17.233-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559692",
    "ThreadId": "244046",
    "Html": "\r\n<p>ok, here's another idea:&nbsp; Are you certain that WinRar supports reading of AES-encrypted zip files?&nbsp; I am not so familiar with the feature set of that tool.&nbsp; Is it possible that WinRar is ignoring the &quot;strong encryption&quot; bit in the zip entry,\r\n when it extracts?&nbsp; Have you compared the extracted output to the original file, for each entry?&nbsp;&nbsp; Have you verified that the output files have the same checksum as the input?</p>\r\n<p>And another suggestion: After creating the zipfile and saving it, and AFTER exiting from the Using clause, open a new Using clause on the same filesystem file.&nbsp; Iterate through the entries and print out or display the Encryption property on each ZipEntry.&nbsp;\r\n what does it say?</p>\r\n<p>You can also try reading and displaying the ZipFile.Info property.&nbsp; This will return a string, containing diagnostic information about each entry in the zipfile.&nbsp; Use this only when reading a new zipfile that had been previously saved.</p>\r\n<p>Also:&nbsp; if you open the zipfile in Windows Explorer, what happens?&nbsp; Can you extract? What message do you get?</p>\r\n<p>And: have you tried WinZip to perform the extraction?&nbsp; V9 and above supports AES encryption. You can download a trial version for free.&nbsp; It's fully functional but it gives you nag screens.</p>\r\n<p>Finally, have you tried the DotNetZip library itself to extract these entries?&nbsp; What if you try extracting in&nbsp;a VB app that you wrote?&nbsp; Does it work?&nbsp; If the entries are password protected, you will get exceptions indicating that fact.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2011-02-02T13:22:38.827-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559693",
    "ThreadId": "244046",
    "Html": "\r\n<p>Cheeso, &nbsp;I have found the issue.<br>\r\n<br>\r\nI created several directories and blank text files to simply test the .AddDirectory functionality and whether or not it&nbsp;persevered&nbsp;the directory structure. &nbsp;\r\n<br>\r\n<br>\r\nAs it turns out, empty text files will extract without requiring a password. &nbsp;If the Zip contains a file with an actual file size it will prompt for a password before extracting.<br>\r\n<br>\r\n<br>\r\nThanks for looking into this for me. &nbsp;The library is great and does exactly what I need it to so I will definitely be donating.</p>\r\n",
    "PostedDate": "2011-02-02T13:22:57.683-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559700",
    "ThreadId": "244046",
    "Html": "\r\n<p>Terrific, glad you tracked it down.&nbsp; Yes - I should have thought of that.&nbsp; DotNetZip does not encrypt a zero-length file entry, so anyone can extract it.</p>\r\n<p>In a zipfile, since the metadata itself is unencrypted, it is easy to see that an encrypted entry is zero bytes in length, even if you don't have the password.&nbsp; Therefore to encrypt and password-protect such an entry is sort of pointless.&nbsp; I decided\r\n that when that happened, I'd eliminate the encryption completely for that entry.&nbsp;&nbsp; I'm still not sure that was the right design decision.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2011-02-02T13:31:49.367-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "565097",
    "ThreadId": "244046",
    "Html": "<p>hi,</p>\n<p>i am facing a problem in adding password</p>\n<p>below is the code</p>\n<p>Using ZipFile1 As New Ionic.Zip.ZipFile<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ZipFile1.Encryption = Ionic.Zip.EncryptionAlgorithm.WinZipAes256<br /> <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ZipFile1.Strategy = Ionic.Zlib.CompressionStrategy.Default<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ZipFile1.AddFile(\"L:\\temp\\abc.xls\", \"\")<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ZipFile1.AddFile(\"c:\\Desktop\\2005_Annual_Report.pdf\", \"\")<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ZipFile1.AddFile(\"ReadMe.txt\")<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ZipFile1.Password = \"sdewfjjedc\"<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ZipFile1.Save(\"zippedfile\")<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Using</p>\n<p>the error is generated in the last line..Save</p>\n<p>it says Supply a password to use AES encryption</p>",
    "PostedDate": "2011-02-12T05:08:59.293-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "565105",
    "ThreadId": "244046",
    "Html": "<p>The problem got solved. !!!!!</p>\n<p>i need to put the zipfile1.password line immediately below the zipfile1.encryption before adding files to the zip</p>\n<p>however the zip file getting created is without .zip extension</p>\n<p>apologies...just adding .zip to the file and rebuilding the application solved it.</p>\n<p>wanted to delete this post..cant find a button :D</p>",
    "PostedDate": "2011-02-12T05:39:10.147-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]