iPhone zip压缩与解压

ziparchive是基于开源代码"MiniZip"的zip压缩与解压的Objective-C 的Class,使用起来非常的简单.你只需要把代码加进你的工程,然后把zlib库添加到工程就可以了.

ziparchive可以在googlecode上下载,地址如下:http://code.google.com/p/ziparchive/

参考贴:http://www.iphonedevsdk.com/foru ... p-format-files.html

 

压缩:

   ZipArchive可以压缩多个文件,只需要把文件一一addFileToZip即可.

ziparchive是基于开源代码"MiniZip"的zip压缩与解压的Objective-C 的Class,使用起来非常的简单.你只需要把代码加进你的工程,然后把zlib库添加到工程就可以了.

ziparchive可以在googlecode上下载,地址如下:http://code.google.com/p/ziparchive/

参考贴:http://www.iphonedevsdk.com/foru ... p-format-files.html

 

压缩:

   ZipArchive可以压缩多个文件,只需要把文件一一addFileToZip即可.

ZipArchive* zip = [[ZipArchivealloc] init];

NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);

NSString *dcoumentpath = ([pathscount] > 0) ? [paths objectAtIndex:0] : nil;

 NSString* l_zipfile = [dcoumentpathstringByAppendingString:@"/test.zip"] ;

 

NSString* image1 = [dcoumentpathstringByAppendingString:@"/image1.jpg"] ;         

NSString* image2 = [dcoumentpathstringByAppendingString:@"/image2.jpg"] ; 

 

BOOL ret = [zip CreateZipFile2:l_zipfile];

ret = [zip addFileToZip:image1newname:@"image1.jpg"];

ret = [zip addFileToZip:image2newname:@"image2.jpg"];

if( ![zip CloseZipFile2] )

{

  l_zipfile= @"";

}

[zip release];

解压缩:

ZipArchive* zip = [[ZipArchivealloc] init];

              NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);

               NSString *dcoumentpath = ([paths count] > 0) ? [pathsobjectAtIndex:0] : nil;

              

               NSString* l_zipfile = [dcoumentpath stringByAppendingString:@"/test.zip"];

               NSString* unzipto = [dcoumentpathstringByAppendingString:@"/test"] ;

               if( [zip UnzipOpenFile:l_zipfile] )

               {

                   BOOL ret = [zip UnzipFileTo:unziptooverWrite:YES];

                  if( NO==ret )

                  {

                  }

                  [zip UnzipCloseFile];

              }

              [zip release];

复制代码

解压缩:

     ZipArchive* zip = [[ZipArchivealloc] init];

              NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);

             NSString *dcoumentpath = ([paths count] > 0) ? [pathsobjectAtIndex:0] : nil;

            

             NSString* l_zipfile = [dcoumentpathstringByAppendingString:@"/test.zip"] ;

             NSString* unzipto = [dcoumentpath stringByAppendingString:@"/test"];

              if( [zip UnzipOpenFile:l_zipfile] )

              {

                  BOOL ret = [zip UnzipFileTo:unziptooverWrite:YES];

                  if( NO==ret )

                 {

                 }

                 [zip UnzipCloseFile];

             }

             [zip release];

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值