我正在使用 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;
}