问题
i am downloading a zip file and saving in document directory. and then making unzip using the ssziparchive . but not getting any data from the zip file .how to fetch the data .and i am not able to see where is my unzip file .in document directory only i am getting this.
i have used this code to make zip as un zip file
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:@"image.zip"];
NSString *zipPath =fullPath;
NSString *destinationPath =[documentsDirectory stringByAppendingPathComponent:@"unZipimage"];
NSLog(@"zip path==%@",zipPath);
NSLog(@"dest path==%@",destinationPath);
//
[SSZipArchive unzipFileAtPath:zipPath toDestination:destinationPath];
回答1:
Zip Data store in Bundle To document directory as below.
get Path from Bundle.
NSString *StrZIP = [[NSBundle mainBundle] pathForResource:@"TestZIP" ofType:@"zip"];
convert
Zip
ToNSData
NSData *ZIPData = [NSData dataWithContentsOfFile:StrZIP];
Store Zip file in document directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory NSString *filePath = [documentsPath stringByAppendingPathComponent:@"TestZIP.zip"]; //Add the file name [ZIPData writeToFile:filePath atomically:YES]; //Write the file
TeztZIP is unzip using
SSZipArchive
at documentsPath[SSZipArchive unzipFileAtPath:filePath toDestination:documentsPath];
OUTPUT :
来源:https://stackoverflow.com/questions/28060790/from-the-zip-file-not-able-to-fetch-data-from-the-document-directory