如何可以打包文件夹成zip吗
现在火山PC里有方法可以打包文件夹成zip吗,谢谢执行运行 调用DOS命令,操作winrar 可以用zlib压缩文件夹吗 不太清楚,我也想知道。 我也想知道 火山PC有方法可以压缩文件夹吗,需要知道压缩进度或者压缩结果的 /*
HZIP newZipFile = CreateZip(full_filepath_,0);
ZIP_Folder(str_path, str_path, full_filepath_,newZipFile);
CloseZip(newZipFile); //关闭zip文件
*/
ZIP_Folder(const wxString &in_epub_folder,
const wxString &in_folder_old,
const wxString &out_filename,
HZIP newZipFile)
{
if (!wxFileName::Exists(in_folder))
{
return ;
}
//建立一个空的压缩文件
//HZIP newZipFile = CreateZip(out_filename,0);
TCHAR* ch_folder;
TCHAR* ch_filename;
TCHAR* ch_fullpath;
wxDir dir(in_folder);
wxString filename;
wxString file_and_folder_short_name;
int iPos=0;
bool cont = dir.GetFirst(&filename, wxEmptyString, wxDIR_DEFAULT);
int iStartPos = 0;
while (cont)
{
wxString file = in_folder + wxFILE_SEP_PATH + filename;
iPos = file.Find(in_folder_old);
if(wxString::npos != iPos )
{
iStartPos = in_folder_old.length();
file_and_folder_short_name = file.substr(iStartPos);
}
const char* file_char = file;
if (wxFileExists(file))
{
if((_access(file, 2)) != -1)
{
file_and_folder_short_name = file_and_folder_short_name.substr(1);
ch_filename = new TCHAR;
lstrcpy(ch_filename, file_and_folder_short_name);
//File to Zip
ch_fullpath = new TCHAR;
lstrcpy(ch_fullpath, file);
ZipAdd(newZipFile, ch_filename, ch_fullpath); //将文件添加到zip文件中
}
}
else
{
file_and_folder_short_name =file_and_folder_short_name.substr(1)+"/";
ch_folder = new TCHAR;
lstrcpy(ch_folder, file_and_folder_short_name);
ZipAdd(newZipFile, ch_folder, NULL); //建立一个文件夹
ZIP_Folder(file,in_folder_old,out_filename,newZipFile);
}
cont = dir.GetNext(&filename);
}
return ;
}
完
使用的方法:
/*
HZIP newZipFile = CreateZip(full_filepath_,0);
ZIP_Folder(str_path, str_path, full_filepath_,newZipFile);
CloseZip(newZipFile); //关闭zip文件
*/
没有,只能自己封装
页:
[1]