我正在使用ZipArchive解压缩,但是将zip的内容解压缩到以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;
}
最佳答案
您需要将自定义路径附加到文档目录。
[zipArchive UnzipFileTo:[[self documentDirectory] stringByAppendingPathComponent:@"My folder"] overWrite:YES];
关于ios - zip在iOS上解压缩到文档文件夹,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10725176/