IOS下利用ziparchive解压缩zip文件
来源:互联网 发布:java程序员年终总结 编辑:程序博客网 时间:2024/05/18 03:49
ziparchive是基于开源代码”MiniZip”的zip压缩与解压的Objective-C 的Class,使用起来非常的简单
方法:从http://code.google.com/p/ziparchive/ 上下载ZipArchive.zip,解压后将代码加入工程中,并且把libz.dylib库添加到工程中
使用方法:
1. 压缩:ZipArchive可以压缩多个文件,只需要把文件一一addFileToZip即可
- ZipArchive* zip = [[ZipArchive alloc] init];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentpath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
- NSString* l_zipfile = [documentpath stringByAppendingString:@"/test.zip"] ;
- NSString* image1 = [documentpath stringByAppendingString:@"/image1.jpg"] ;
- NSString* image2 = [documentpath stringByAppendingString:@"/image2.jpg"] ;
- BOOL ret = [zip CreateZipFile2:l_zipfile];
- ret = [zip addFileToZip:image1 newname:@"image1.jpg"];
- ret = [zip addFileToZip:image2 newname:@"image2.jpg"];
- if( ![zip CloseZipFile2] )
- {
- l_zipfile = @"";
- }
- [zip release];
2. 解压缩:
- ZipArchive* zip = [[ZipArchive alloc] init];
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentpath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil;
- NSString* l_zipfile = [documentpath stringByAppendingString:@"/test.zip"] ;
- NSString* unzipto = [documentpath stringByAppendingString:@"/test"] ;
- if( [zip UnzipOpenFile:l_zipfile] )
- {
- BOOL ret = [zip UnzipFileTo:unzipto overWrite:YES];
- if( NO==ret )
- {
- }
- [zip UnzipCloseFile];
- }
- [zip release];
0 0
- IOS下利用ziparchive解压缩zip文件
- IOS下利用ziparchive解压缩zip文件
- IOS下利用ziparchive解压缩zip文件
- IOS下利用ziparchive解压缩zip文件
- IOS下利用ziparchive解压缩zip文件
- IOS下利用ziparchive解压缩zip文件
- IOS下利用ziparchive解压缩zip文件
- IOS下利用ziparchive解压缩zip文件
- [iOS-GQiang]IOS下利用ziparchive解压缩zip文件
- 利用ziparchive快捷解压缩服务器上的zip压缩包
- IOS开发之----使用ZipArchive解压缩文件
- IOS开发之----使用ZipArchive解压缩文件
- PHP之Zip扩展,解压缩文件,ZipArchive类
- iOS下载解压缩文件-ZipArchive与文件上传
- DOS下解压缩ZIP文件
- IOS解压缩和压缩zip文件
- iOS开发之解压缩zip文件
- iOS开发之解压缩zip文件
- hibernate参考文档
- 图像处理与计算机视觉:基础,经典以及最近发展(1)序
- Bootstrap创建表单(一)
- EM算法
- PHP安装和使用xhprof
- IOS下利用ziparchive解压缩zip文件
- LSGO软件技术团队2015~2016学年第九周(1026~1101)总结
- iOS 使用ZipArchive压缩文件
- 107_Kruskal 最小生成树
- 只留痴人说梦声——2015年年总
- 图像处理与计算机视觉:基础,经典以及最近发展(2)图像处理与计算机视觉相关的书籍
- 2016年01月01日
- 数据库之运算符和函数
- android之shape基础