简体   繁体   English

检查存档是否在Sevenzipsharp(C#)中受密码保护

[英]Checking whether an archive is password-protected in Sevenzipsharp (C#)

I'm writing an window form similar to 7-Zip, my problem is in the extraction part, I don't know how to check if the archive I want to extract is password protected or not. 我正在编写类似于7-Zip的窗口表单,我的问题出在提取部分,我不知道如何检查我要提取的档案是否受密码保护。 Any idea? 任何想法?

I've got the solution: just check the extractor before extracting the archive: 我有解决方案:只需在提取存档之前检查提取器即可:

if (fileExtractor.Check())
{
   fileExtractor.BeginExtractArchive(destination_dir);
}

Doing it this way the fileExtractor.Check() will be false , if the archive requires a password, and you're not providing the password for it or the password is not correct. 如果归档文件需要密码,并且您没有为其提供密码或密码不正确,以这种方式将fileExtractor.Check()设为false

It depends on the archive type. 这取决于存档类型。 The ZIP specification describes how it's done for ZIP, although it's not very robust apparently. ZIP规范描述了它对ZIP的完成方式,尽管它显然不是很健壮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM