mattconnolly / ZipArchive

zip archive processing for Cocoa - iPhone and OS X
http://code.google.com/p/ziparchive/
MIT License
840 stars 260 forks source link

UnzipOpenFile doesn't work #45

Closed Borys216307 closed 6 years ago

Borys216307 commented 9 years ago

I have used ZipArchive to zip and unzip some file, but UnzipOpenFile returns nil. Please help me on this.

ZipArchive* za = [[ZipArchive alloc] init];

                if([[NSFileManager defaultManager] fileExistsAtPath:zipFolder]) {
                    NSLog(@"File exists at path: %@", zipFolder);
                } else {
                    NSLog(@"File does not exists at path: %@", zipFolder);
                }

                if( [za UnzipOpenFile: zipFolder] ) {
                    if( [za UnzipFileTo:outputFolder overWrite:YES] != NO ) {
                        NSLog(@"Pics : unzip successfully");

                        [[NSNotificationCenter defaultCenter] postNotificationName:kNotificationArticleLoadedFromiCloud object:nil];
                    }
                    [za UnzipCloseFile];
                }
TechD-Robin commented 9 years ago

maybe your zipFolder need with a zip filename like this :

NSString documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSString zipPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"zipFile.zip"]]; if ( [za unzipOpenFile: zipPath] ) { //... }


hope it helps u.