我有这个代码下解压缩文件夹。 它工作,但我不知道如何改变提取目录。 每次,它都将文件夹提取到我的程序的。exe文件所在的目录中。 我试过一些东西,但每次,它都在那里提取。 我要选择目录。
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);
我会说,在-o参数后面编写extractDirectory的方式有问题,但不确定。 谢谢你的任何帮助。
感谢一些注释,我发现-o参数在WinRAR中不存在,这就是解决方案。
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);
谢谢大家。