ZipArchive 上面讲的都是Memory压缩与解压,ZipArchive主要是对文档进行处理。 昨天在上述方法不成功的情况下,我把获取的data数据savetofile,然后再处理,理论上是可行的,但是由于服务器有误,获取的数据不对,所以我怎么都解压不成功!!!! 示例如下: Objective-C class used to zip / unzip compressed zip file.
Usage: Add all the files to you project, and and framework libz.1.2.3.dylib.
include ZipArchive.h using
#import "ZipArchive/ZipArchive.h"//* create zip file
ZipArchive* zipFile =[[ZipArchive alloc] init];
[zipFile CreateZipFile2:@"zipfilename"]; // A
OR
[[zipFile CreateZipFile2:@"zipfilename" Password:@"your password"];// if password needed,//empty password will get same result as A[zipFile addFileToZip:@"fullpath of the file" newname:@"new name of the file without path"];
....add any number of files here
[zipFile CloseZipFile2];
[zipFile release]; // remember to release the object//* unzip compressed file
ZipArchive* zipFile =[[ZipArchive alloc] init];
[zipFile UnzipOpenFile:@"zip file name"]; // B (the zip got no password)//OR//[zipFile UnzipOpenFile:@"zip file name" Password:@"password" ];[zipFile UnzipFileTo:@"output path" overwrite:YES];
[zipFile UnzipCloseFile];
[zipFile release];