使用c++打包解压软件,实现压缩文件的解压
常用WinRAR Bandizip等软件 注意版权
这类软件除了平时使用的图形界面形式,通常可以使用命令行CMD调用,WinRAR自带说明书、Bandizip的说明
推荐使用Bandizip,使用方便、通用性强、还可以避免不必要的问题
string running_path = _pgmptr;//获取程序运行的目录
string winrar_path = "WinRAR.exe";
winrar_path = running_path.substr(0, running_path.find_last_of("\\") + 1) + winrar_path;
unzip = "\""+winrar_path + "\"" + " x C:\\gacos_temp\\" + txt_file.get_name() + ".tar.gz C:\\gacos_temp\\" + txt_file.get_name() + "\\";
std::cout << unzip << endl;
std::system(unzip.c_str());
注意
- WinRAR Bandizip的大部分命令都可以通用
- 建议将exe文件放在软件编译目录
- 使用绝对路径,防止系统调用本地不同版本软件,引起其他问题。