zipArchive解压缩到iOS上的文档文件夹

我正在使用ZipArchive解压缩,但是将zip的内容解压缩到我的文档的子文件夹中,而不是直接放到我的文档文件夹中。 有谁知道我可以改变,以确保它保存到我想要的目录?

-(void) unZipUpdateArchiveAtPath: (NSString *)zipPath { NSLog(@"UNZIP Update PATH: %@", zipPath); ZipArchive *zipArchive = [[ZipArchive alloc] init]; if ([zipArchive UnzipOpenFile:zipPath]) { if ([zipArchive UnzipFileTo:[self documentDirectory] overWrite:YES]) { NSLog(@"Archive unzip success"); [zipArchive UnzipCloseFile]; } else { NSLog(@"Failure to unzip archive"); } } else { NSLog(@"Failure to open archive"); } } #pragma mark - Application's Documents directory -(NSString *)documentDirectory { NSArray *documentDirectories = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentDirectory = [documentDirectories objectAtIndex:0]; NSLog(@"docDirectory IS %@", documentDirectory); return documentDirectory; } 

您需要将您的自定义path附加到您的文档目录。

 [zipArchive UnzipFileTo:[[self documentDirectory] stringByAppendingPathComponent:@"My folder"] overWrite:YES]; 
Interesting Posts