Search code examples
iphoneiosobjective-cnsfilemanagerphp-ziparchive

How to zip a folder using ZipArchive in iphone?


I have a folder in the documents directory that needs to be zipped.I was able to zip regular files but i was not able to zip folders.

I referred the following link How to zip folders in iPhone SDK? But here the files in the folder are zipped separately.I would like to zip the entire folder instead of having to deal with exploring the contents(files/folders) inside the directory and zipping them one by one.

Is it possible to do this with the ZipArchive library. If it is could some one please explain by posting the necessary code?

Thank You.


Solution

  • You can't do that with ZipArchive but have a look at SSZipArchive it has a + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath; method you could use.