[
  {
    "Id": "457363",
    "ThreadId": "216553",
    "Html": "<p>Hi Cheeso,</p>\r\n<p>Is it possible to test a zip before extraction to see if it has a password?<br>I would like to prompt if it does and use this to extact the protected zip.</p>\r\n<p>Thanks.</p>",
    "PostedDate": "2010-06-18T11:14:31.02-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "457374",
    "ThreadId": "216553",
    "Html": "<p>The password is not on the zip file, but on the individual entries.&nbsp; It's possible to have some entries with a password, some not.&nbsp; It's also possible to have different passwords on different entries.</p>\r\n<p>if you'd like to determine if there is any password required on any entry, you can&nbsp;examine the ZipEntry.UsesEncryption property, for each entry. But that wouldn't allow you to just prompt once for a password.</p>\r\n<p>You'd still need to handle the case where the passwords across different entries differ, or the case where the user enters an incorrect password.</p>\r\n<p>The way I do this in my apps is to handle the BadPasswordException within the call to ZipEntry.Extract().&nbsp; When that happens, I prompt, and try again (up to a&nbsp;limited number of retries).</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-06-18T11:48:33.86-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "457602",
    "ThreadId": "216553",
    "Html": "<p>I see, I've caught the exception you mentioned, works great. Thanks.</p>\r\n<p>I've noticed when saving a zip it takes around ten seconds to start if I use &quot;zip.Encryption = EncryptionAlgorithm.PkzipWeak&quot; (or do not specify) Is this normal?</p>",
    "PostedDate": "2010-06-19T10:45:09.623-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "457728",
    "ThreadId": "216553",
    "Html": "<p>About the 10-second latency, no I've never seen that or heard of that, so I'd say it's not normal.</p>\r\n<p>Not sure what would cause that.&nbsp;</p>\r\n<p>To diagnose it, i<span id=\"_mce_start\" style=\"line-height:0;display:none\">﻿</span>f you have Visual Stud<span id=\"_mce_start\" style=\"line-height:0;display:none\">﻿</span><span id=\"_mce_start\" style=\"line-height:0;display:none\">﻿</span>io you could use the profiler to examine where the time goes.&nbsp; <span id=\"_mce_start\" style=\"line-height:0;display:none\">﻿</span></p>\r\n<p><span id=\"_mce_start\" style=\"line-height:0;display:none\">﻿</span><span id=\"_mce_start\" style=\"line-height:0;display:none\">﻿</span><span id=\"_mce_start\" style=\"line-height:0;display:none\">﻿</span><span id=\"_mce_end\" style=\"line-height:0;display:none\">﻿</span></p>\r\n<p><span id=\"_mce_end\" style=\"line-height:0;display:none\">﻿</span></p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-06-20T05:55:16.237-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "458399",
    "ThreadId": "216553",
    "Html": "<p>Hi Cheeso, I'm using Visual Studio 2008 Profressional - I believe only the team versions come with profiler?<br>I cannot see any reason why it has this delay - only with PKZipWeak?</p>\r\n<p>&nbsp;</p>\r\n<p>\r\n<div style=\"color:black;background-color:white\">\r\n<pre>    <span style=\"color:blue\">Private</span> <span style=\"color:blue\">Sub</span> zipUpFile(<span style=\"color:blue\">ByVal</span> sender <span style=\"color:blue\">As</span> <span style=\"color:blue\">Object</span>, <span style=\"color:blue\">ByVal</span> e <span style=\"color:blue\">As</span> DoWorkEventArgs)\r\n\r\n        <span style=\"color:blue\">Dim</span> extractCancelled <span style=\"color:blue\">As</span> <span style=\"color:blue\">Boolean</span> = <span style=\"color:blue\">False</span>\r\n        <span style=\"color:blue\">Dim</span> args() <span style=\"color:blue\">As</span> <span style=\"color:blue\">String</span> = e.Argument\r\n        <span style=\"color:blue\">Dim</span> FileToZip <span style=\"color:blue\">As</span> <span style=\"color:blue\">String</span> = args(0)\r\n        <span style=\"color:blue\">Dim</span> ZipDir <span style=\"color:blue\">As</span> <span style=\"color:blue\">String</span> = args(1)\r\n        <span style=\"color:blue\">Dim</span> ZipPassword <span style=\"color:blue\">As</span> <span style=\"color:blue\">String</span> = args(2)\r\n        <span style=\"color:blue\">Dim</span> ZipAES <span style=\"color:blue\">As</span> <span style=\"color:blue\">Boolean</span> = args(3)\r\n\r\n        <span style=\"color:blue\">Try</span>\r\n            <span style=\"color:blue\">Using</span> zip <span style=\"color:blue\">As</span> ZipFile = <span style=\"color:blue\">New</span> ZipFile\r\n                <span style=\"color:blue\">If</span> ZipPassword &lt;&gt; <span style=\"color:blue\">Nothing</span> <span style=\"color:blue\">Then</span>\r\n                    zip.Password = ZipPassword  <span style=\"color:green\">' do not forget this!</span>\r\n                    <span style=\"color:blue\">If</span> ZipAES <span style=\"color:blue\">Then</span>\r\n                        zip.Encryption = EncryptionAlgorithm.WinZipAes256 <span style=\"color:green\">'Encrypt AES256</span>\r\n                    <span style=\"color:blue\">End</span> <span style=\"color:blue\">If</span>\r\n                <span style=\"color:blue\">End</span> <span style=\"color:blue\">If</span>\r\n                zip.AddFile(FileToZip, <span style=\"color:#a31515\">&quot;&quot;</span>)\r\n                zip.Comment = (<span style=\"color:#a31515\">&quot;This zip file was created at &quot;</span> &amp; DateTime.Now.ToString(<span style=\"color:#a31515\">&quot;G&quot;</span>)) &amp; <span style=\"color:#a31515\">&quot; By &quot;</span> &amp; GetFullName(SystemInformation.UserName)\r\n                <span style=\"color:blue\">AddHandler</span> zip.SaveProgress, <span style=\"color:blue\">New</span> EventHandler(Of SaveProgressEventArgs)(<span style=\"color:blue\">AddressOf</span> <span style=\"color:blue\">Me</span>.zip_CompressProgress)\r\n                zip.Save(ZipDir)\r\n            <span style=\"color:blue\">End</span> <span style=\"color:blue\">Using</span>\r\n        <span style=\"color:blue\">Catch</span> ex1 <span style=\"color:blue\">As</span> Exception\r\n            MessageBox.Show(ex1.ToString)\r\n        <span style=\"color:blue\">End</span> <span style=\"color:blue\">Try</span>\r\n\r\n    <span style=\"color:blue\">End</span> <span style=\"color:blue\">Sub</span>\r\n</pre>\r\n</div>\r\n</p>",
    "PostedDate": "2010-06-22T01:58:28.217-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "458919",
    "ThreadId": "216553",
    "Html": "I'm not sure which versions of the Visual Studio tool have the profiler, but I do know that a profiler would quickly pinpoint the source of the 10s delay in your app.\r\nIf not Visual Studio profiler, maybe there's a third party profiler you can use. Maybe you can use a trial version of VS with the profiler (I don't know).  All I'm saying is a profiler would give you the answer quickly.\r\n\r\nYour code looks fine, and I cannot think of anything that would lead to a 10s delay.\r\nIs this on a PC, full framework?  (not a mobile device, right?  not compact framework?) \r\n\r\nIt could be a transient effect.  If for some reason the use of zip encryption requires the loading of an external assembly, the first time through may result in a delay. subsequent runs through the same code (in the same process) won't incur that cost and won't give you the delay. \r\n\r\nSo if you don't have a profiler, try running 10 iterations and see if the delay happens each time.\r\n\r\nJust a few ideas...",
    "PostedDate": "2010-06-23T05:31:18.903-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]