2013-01-05 76 views
0

我正在使用ZipKit for iOS我试图压缩我的Documents文件夹的子目录。我提到了这个question,但它似乎仍然没有工作。我的代码是:iOS zip子目录文件夹

ZKFileArchive *archive = [ZKFileArchive archiveWithArchivePath:@"Documents/test.zip"]; 
NSInteger result = [archive deflateDirectory:@"/Documents/test" relativeToPath:@"/Documents" usingResourceFork:NO]; 

我有一个“测试”子目录,我想它压缩成test.zip。 “结果”返回1,但不出现zip文件夹。有任何想法吗?

回答

0

想通了。对于任何具有相同问题的人,只需将实际文档文件夹的相对路径设置为:

NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentFolder = [documentPath objectAtIndex:0]; 

ZKFileArchive *archive = [ZKFileArchive archiveWithArchivePath:@"Documents/test.zip"]; 
NSInteger result = [archive deflateDirectory:@"/Documents/test" relativeToPath:documentFolder usingResourceFork:NO];