简体   繁体   中英

Unzip with WinRar in Qt(C++) using QProcess - extract directory problem

I have this code bellow to unzip folder. It works but I do not know how to change extraction directory. Everytime, it extracts folder to directory where is my.exe file of my program. I tried some things but every time, it just extracts there. I want to choose directory.

QString program = "c:/program files/winRAR/winRAR.exe";

QStringList arguments;
arguments << "x"; // extract files and directories
arguments << "-y"; // suppress questions
arguments << "-o" + QDir::toNativeSeparators(extractDirectory);
arguments << QDir::toNativeSeparators(zipFileDirectory);

QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);

I would say, there is problem in way of writing extractDirectory behind -o argument but not sure. Thank you for any help.

Thanks to some comments, I find out that -o argument doesnt exist in WinRAR and this is solution.

QString program = "c:/program files/winRAR/winRAR.exe";

QStringList arguments;
arguments << "x"; // extract files and directories
arguments << "-y"; // suppress questions
arguments << QDir::toNativeSeparators(zipFileDirectory);
arguments << QDir::toNativeSeparators(extractDirectory);

QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);

Thank you everyone.

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.

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