How to zip file
<p>I want to zip file in my application. Can anybody tell me the code exactly.
I have used this code to unzip file:</p>

<p>I used: ZipArchive.h</p>

<pre><code>self.fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSLog(@"document directory path:%@",paths);

self.documentDirectory = [paths objectAtIndex:0];

NSString *filePath = [NSString stringWithFormat:@"%@/abc", self.documentDirectory];

NSLog(@"file path is:%@",filePath);

NSString *fileContent = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"data.zip"];


NSData *unzipData = [NSData dataWithContentsOfFile:fileContent];

[self.fileManager createFileAtPath:filePath contents:unzipData attributes:nil];

// here we go, unzipping code

ZipArchive *zipArchive = [[ZipArchive alloc] init];

if ([zipArchive UnzipOpenFile:filePath])
{
  if ([zipArchive UnzipFileTo:self.documentDirectory overWrite:NO])
  {
     NSLog(@"Archive unzip success");
     [self.fileManager removeItemAtPath:filePath error:NULL];
  }
  else
  {
     NSLog(@"Failure to unzip archive");
  }
}
else
{
   NSLog(@"Failure to open archive");
}
[zipArchive release];
</code></pre>
