简体   繁体   English

使用C#提取受密码保护的sfx存档

[英]extract password protected sfx archive using c#

I have WinRAR SFX file. 我有WinRAR SFX文件。 I know that I can extract archive using following code: 我知道我可以使用以下代码提取存档:

Process process = new Process();
process.StartInfo.FileName = "unrar.exe";
process.StartInfo.Arguments = "x file.rar d:\myFolder";
process.Start();
process.WaitForExit();   

But how can I extract SFX file when it have known password? 但是,如果知道密码,如何提取SFX文件?

Assuming your password is mypassword , you need to change your arguments line to this: 假设您的密码是mypassword ,则需要将参数行更改为此:

process.StartInfo.Arguments = @"x -pmypassword file.rar d:\myFolder";

Note that you shouldn't put a space after the -p before your password - or it'll prompt you. 请注意,您不应在密码前-p后放置空格-否则会提示您。

I also added a @ to mark the string as a literal, otherwise it'll try to treat the \\m in the file name as an escape character. 我还添加了一个@以将该字符串标记为文字,否则它将尝试将文件名中的\\m视为转义字符。

you can use -p as parameter 您可以使用-p作为参数
Assuming your password is 123456 假设您的密码是123456

Process process = new Process();
process.StartInfo.FileName = "unrar.exe";
process.StartInfo.Arguments = "x -p123456 file.rar d:\myFolder";
process.Start();
process.WaitForExit(); 

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

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