Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>first you download Objective-zip example from <a href="http://code.google.com/p/objective-zip/downloads/list" rel="nofollow">http://code.google.com/p/objective-zip/downloads/list</a></p> <blockquote> <p>in this example Find and copy three folder Objective-Zip, MiniZip and ZLib drag in to your project</p> <p>import two class in you .m class "ZipFile.h" and "ZipWriteStream.h"</p> <p>create method of zip my code is :-</p> </blockquote> <pre><code>-(IBAction)Zip{ self.fileManager = [NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory , NSUserDomainMask, YES); NSString *ZipLibrary = [paths objectAtIndex:0]; NSString *fullPathToFile = [ZipLibrary stringByAppendingPathComponent:@"backUp.zip"]; //[self.fileManager createDirectoryAtPath:fullPathToFile attributes:nil]; //self.documentsDir = [paths objectAtIndex:0]; ZipFile *zipFile = [[ZipFile alloc]initWithFileName:fullPathToFile mode:ZipFileModeCreate]; NSError *error = nil; self.fileManager = [NSFileManager defaultManager]; NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES); self.documentsDir = [paths1 objectAtIndex:0]; NSArray *files = [[NSFileManager defaultManager]contentsOfDirectoryAtPath:self.documentsDir error:&amp;error]; //for(NSString *filename in files){ for(int i = 0;i&lt;files.count;i++){ id myArrayElement = [files objectAtIndex:i]; if([myArrayElement rangeOfString:@".png" ].location !=NSNotFound){ NSLog(@"add %@", myArrayElement); NSString *path = [self.documentsDir stringByAppendingPathComponent:myArrayElement]; NSDictionary *attributes = [[NSFileManager defaultManager]attributesOfItemAtPath:path error:&amp;error]; NSDate *Date = [attributes objectForKey:NSFileCreationDate]; ZipWriteStream *streem = [zipFile writeFileInZipWithName:myArrayElement fileDate:Date compressionLevel:ZipCompressionLevelBest]; NSData *data = [NSData dataWithContentsOfFile:path]; // NSLog(@"%d",data); [streem writeData:data]; [streem finishedWriting]; }else if([myArrayElement rangeOfString:@".txt" ].location !=NSNotFound) { NSString *path = [self.documentsDir stringByAppendingPathComponent:myArrayElement]; NSDictionary *attributes = [[NSFileManager defaultManager]attributesOfItemAtPath:path error:&amp;error]; NSDate *Date = [attributes objectForKey:NSFileCreationDate]; ZipWriteStream *streem = [zipFile writeFileInZipWithName:myArrayElement fileDate:Date compressionLevel:ZipCompressionLevelBest]; NSData *data = [NSData dataWithContentsOfFile:path]; // NSLog(@"%d",data); [streem writeData:data]; [streem finishedWriting]; } } [self testcsv]; [zipFile close]; } </code></pre> <p>your documents directory saved item .png and .txt files zipping in Library folder with backup.zip i hope this is helps </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload