解压 zip 文件不起作用
我是 iPhone 编程新手..有人可以帮我解决以下问题吗
我正在使用以下代码来解压 zip 文件..它不起作用...并打印 NSLog(@"无法解压缩存档");留言
self.fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
self.documentsDir = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/temp", self.documentsDir];
NSString *updateURL = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"bmlgg.zip"];
NSLog(@"Checking update at : %@", updateURL);
NSLog(@"Checking filepath at : %@", filePath);
ZipArchive *zipArchive = [[ZipArchive alloc] init];
if([zipArchive UnzipOpenFile:updateURL]) {
if ([zipArchive UnzipFileTo:filePath overWrite:YES]) {
//unzipped successfully
NSLog(@"Archive unzip Success");
//[self.fileManager removeItemAtPath:filePath error:NULL];
} else {
NSLog(@"Failure To Unzip Archive");
}
} else {
NSLog(@"Failure To Open Archive");
}
[zipArchive release];
谢谢....
i am new to iPhone programming..can anybody help me out from the following problem
i am using the fallowing code to unarcive a zip file.. its not working... and printing the NSLog(@"Failure To Unzip Archive"); msg
self.fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
self.documentsDir = [paths objectAtIndex:0];
NSString *filePath = [NSString stringWithFormat:@"%@/temp", self.documentsDir];
NSString *updateURL = [[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"bmlgg.zip"];
NSLog(@"Checking update at : %@", updateURL);
NSLog(@"Checking filepath at : %@", filePath);
ZipArchive *zipArchive = [[ZipArchive alloc] init];
if([zipArchive UnzipOpenFile:updateURL]) {
if ([zipArchive UnzipFileTo:filePath overWrite:YES]) {
//unzipped successfully
NSLog(@"Archive unzip Success");
//[self.fileManager removeItemAtPath:filePath error:NULL];
} else {
NSLog(@"Failure To Unzip Archive");
}
} else {
NSLog(@"Failure To Open Archive");
}
[zipArchive release];
thank u....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我得到了解决方案...
问题是 zip 文件无法识别...
我更改了以下代码
这对我有帮助
i got the solution...
the problem is the zip file is not recognized...
i changed the fallowing code
this helped me