我正在使用zip和unzip对象,为此,我使用ziparchive类,我能够压缩文件但解压缩文件时出现问题,以下是我的代码
NSString *str1;
ZipArchive *za = [[ZipArchive alloc] init];
[za CreateZipFile2:zipFile];
NSLog(@"this is my whole new ipad%d",pictureArr.count);
[self calculation];
for (int i=0;i<[pictureArr count]; i++) {
NSString *str = [NSString stringWithFormat:@"%@",[pictureArr objectAtIndex:i]];
NSLog(@"This is my whole new ipad%@",[pictureArr objectAtIndex:i]);
[za addFileToZip:str newname:[pictureArr objectAtIndex:i]];
}
//NSString *textPath = [cachePath stringByAppendingPathComponent:@"text.txt"];
NSString *strUrl = [NSString stringWithString:path];
NSString *strunzip=[docspath stringByAppendingPathComponent:strUrl];
NSLog(@"This is my new file path for strXmlName%@",docspath);
[za addFileToZip:strUrl newname:strXmlName];
NSString *fileContent = [docspath stringByAppendingPathComponent:@"strXmlName.zip"];
NSLog(@"This is my final path for%@",fileContent);
NSString *updateURL = [[NSBundle mainBundle] pathForResource:fileContent ofType:@"zip" inDirectory:@"res"];
if ([za UnzipOpenFile:fileContent]) {
if ([za UnzipFileTo:docspath overWrite:NO]) {
NSLog(@"Archive unzip success");
[fileManager removeItemAtPath:docspath error:NULL];
}
else {
NSLog(@"Failure to unzip archive");
}
/*7405726724,9227669500-agile infoway
*/
}
else {
NSLog(@"Failure to open archive");
}
NSData *unzipData = [NSData dataWithContentsOfFile:fileContent];
fileManager = [NSFileManager defaultManager];
[fileManager createFileAtPath:docspath contents:unzipData attributes:nil];
NSLog(@"This is my file");
[za UnzipOpenFile:path];
BOOL success = [za CloseZipFile2];
NSLog(@"Zipped file with result %d",success);
但它直接从if ([za UnzipOpenFile:fileContent])
出来我不知道为什么它很开心,
我试过的是this
和this
所以请指导我 感谢