ZipArchive 解压zip
来源:互联网 发布:java jar 打包makefile 编辑:程序博客网 时间:2024/05/16 13:50
仿照网上的例子,自己学习了一下.
1.将ZipArchive文件夹添加到项目里面.
2.导入库(libz.dylib或者libz1.2.3.dylib,不知道区别,可能是版本号,反正都可以用)
3.代码
1.将ZipArchive文件夹添加到项目里面.
2.导入库(libz.dylib或者libz1.2.3.dylib,不知道区别,可能是版本号,反正都可以用)
3.代码
- @interface TestViewViewController : UIViewController {
- UIImageView *imageView;
- UIButton *button;
- }
- @property (nonatomic,retain)UIImageView *imageView;
- @property (nonatomic,retain)UIButton *button;
- - (NSString *)dataFilePath:(NSString *)fileName;
- @end
- #import "TestViewViewController.h"
- #import "ZipArchive.h"
- @implementation TestViewViewController
- @synthesize imageView;
- @synthesize button;
- - (void)loadView {
- [super loadView];
- imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 110, 169, 255)];
- button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- button.frame = CGRectMake(0, 0, 100, 50);
- [button addTarget:self action:@selector(myUnZip) forControlEvents:UIControlEventTouchDown];
- [self.view addSubview:imageView];
- [self.view addSubview:button];
- }
- - (void)myUnZip {
- //获取资源文件的路径
- NSString *filePath = [[NSBundle mainBundle] pathForResource:@"demozipfile.zip" ofType:nil];
- BOOL result;
- ZipArchive *zip = [[ZipArchive alloc] init];
- if ([zip UnzipOpenFile:filePath]) {
- result = [zip UnzipFileTo:[self dataFilePath:@"2011"] overWrite:YES];
- [zip UnzipCloseFile];
- }
- if (result) {
- imageView.image = [UIImage imageWithContentsOfFile:[self dataFilePath:@"2011/nga_519887.png"]];
- }
- [zip release];
- }
- -(NSString *)dataFilePath:(NSString *)fileName {
- //获取文件的document文件夹的路径.
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- NSString *documentDiretory = [paths objectAtIndex:0];
- //追加一个路径
- return [documentDiretory stringByAppendingPathComponent:fileName];
- }
- @end
http://fightper.iteye.com/blog/1050203
- ZipArchive 解压zip
- 用ZipArchive添加和解压zip包
- iOS用ZipArchive解压zip包
- PHP ZipArchive 实现压缩解压Zip文件
- iOS开发-用ZipArchive添加和解压zip包
- iOS开发-用ZipArchive添加和解压zip包
- iOS开发-用ZipArchive添加和解压zip包
- ZipArchive 压缩与解压
- PHP扩展类ZipArchive实现压缩解压Zip文件和文件打包下载
- PHP扩展类ZipArchive实现压缩解压Zip文件和文件打包下载
- PHP扩展类ZipArchive实现压缩解压Zip文件和文件打包下载
- PHP扩展类ZipArchive实现压缩解压Zip文件和文件打包下载
- iPhone ziparchive压缩与解压
- IOS 使用ZipArchive解压文件
- PHP 的解压缩ZipArchive中的extractTo()方法 LINUX+nginx环境中解压zip时文件丢失的问题
- ZIP解压
- ZIP解压
- ZIP解压
- Strust2 下载文件 解决中文名称乱码
- 使用 OpenRowSet 和 OpenDataSource 访问 Excel 97-2007
- java运算符优先级
- Linux设备驱动Hello World程序介绍
- Flash自定义事件
- ZipArchive 解压zip
- TCP/IP参考模型
- 多线程 异步实现(通过事件驱动)
- linux 中解析命令行参数(getopt_long用法)
- C语言文件操作函数详解
- VC知识库中关于多线程编程的文章
- iphone开发每日一练1【2011-09-30】
- BW性能监控利器——ST13总结
- 在UIView上添加一个导航栏