源代码:http://code.google.com/p/ziparchive/
压缩文件
BOOL ret = [zip CreateZipFile2:l_zipfile];
// 或者
BOOL ret = [zip CreateZipFile2:l_zipfile Password:@"your password"]; //支持密码 如果密码是空的和上一个效果一样
ret = [zip addFileToZip:l_photo newname:@"photo.jpg"];//添加文件到压缩包中
if( ![zip CloseZipFile2] )
{
// error handler here
}
[zip release];
解压缩文件
ZipArchive* za = [[ZipArchive alloc] init];
if( [za UnzipOpenFile:@"/Volumes/data/testfolder/Archive.zip"] )
// 或者
if( [za UnzipOpenFile:@"/Volumes/data/testfolder/Archive.zip"] Password:@"password of the zip file"] )
//如果密码是空的和上一个效果一样
{
BOOL ret = [za UnzipFileTo:@"/Volumes/data/testfolder/extract" overWrite:YES];
if( NO==ret )
{
// error handler here
}
[za UnzipCloseFile];
}
[za release];