How to validate that a file is a password protected ZIP file, using C#
问题 Given a path to a file, how can I validate that the file is a password-protected zip file? i.e., how would I implement this function? bool IsPasswordProtectedZipFile(string pathToFile) I don't need to unzip the file -- I just need to verify that it's a ZIP and has been protected with some password. Thanks 回答1: Using SharpZipLib, the following code works. And by works I mean entry.IsCrypted returns true or false based on whether or not there is a password for the first entry in the zip file.