I have WinRAR SFX file. 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?
Assuming your password is mypassword , you need to change your arguments line to this:
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.
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.
you can use -p as parameter
Assuming your password is 123456
Process process = new Process();
process.StartInfo.FileName = "unrar.exe";
process.StartInfo.Arguments = "x -p123456 file.rar d:\myFolder";
process.Start();
process.WaitForExit();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.