Search code examples
dotnetzip

How do I know whether the zip file is password protected or not with dotnetzip?


now let's think we got a random zip file so how do I know that file is password protected? cause there ain't a method like

bool IsPasswordProtected(string fileName);

I am asking this cause there are couple of methods to extract entries from a zip file but still I have to use either Extract() or ExtractWithPassword() but to use this I have to know the file that I am going to extract is actually password protected or not. I know the password applies to the entries not to the zip file itself. I checked every methods in the documentation but I couldn't find a suitable method to solve this issue or did I miss something?

Thanks.!


Solution

  • Check the ZipEntry.UsesEncryption property.