使用网上公开的unzip即可,至于解压文件夹中的文件不用你操心,你直接调用unzip中的api即可,unzip会帮你处理,相关参考代码如下:
// 返回True表示没有错误,返回False表示有错误发生,
// strDstPath,目标文件夹,strZipName解压的文件名(含绝对路径)
BOOL CProcessLogic::Unzip( CString strDstPath, CString strZipName )
{
BOOL bExistError = FALSE;
SetCurrentDirectory( strDstPath );
HZIP hz = OpenZip( strZipName, 0 );
if ( hz == NULL )
{
return FALSE;
} ZIPENTRY ze;
GetZipItem( hz, -1, &ze );
int numitems = ze.index;
for ( int i = 0; i < numitems; i++ )
{
GetZipItem( hz, i, &ze );
DWORD dwRet = UnzipItem( hz, i, ze.name ); // 解压有错误
if ( dwRet != 0 )
{
CString strLog;
strLog.Format( _T("[CProcessLogic::Unzip]文件解压错误:%s"), ze.name );
uilog( strLog );
bExistError = TRUE;
}
} CloseZip( hz );
return !bExistError;
}
// 返回True表示没有错误,返回False表示有错误发生,
// strDstPath,目标文件夹,strZipName解压的文件名(含绝对路径)
BOOL CProcessLogic::Unzip( CString strDstPath, CString strZipName )
{
BOOL bExistError = FALSE;
SetCurrentDirectory( strDstPath );
HZIP hz = OpenZip( strZipName, 0 );
if ( hz == NULL )
{
return FALSE;
} ZIPENTRY ze;
GetZipItem( hz, -1, &ze );
int numitems = ze.index;
for ( int i = 0; i < numitems; i++ )
{
GetZipItem( hz, i, &ze );
DWORD dwRet = UnzipItem( hz, i, ze.name ); // 解压有错误
if ( dwRet != 0 )
{
CString strLog;
strLog.Format( _T("[CProcessLogic::Unzip]文件解压错误:%s"), ze.name );
uilog( strLog );
bExistError = TRUE;
}
} CloseZip( hz );
return !bExistError;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货