Search Results

Search found 1 results on 1 pages for 'user345131'.

Page 1/1 | 1 

  • ZipArchive on the iPhone unzips files but they are empty

    - by user345131
    I'm trying to use ZipArchive on the iPhone to unzip a simple text file. It returns with no error but the file is empty. I would love to know why this doesn't work. I am using the following methods: -(void)alert:(NSString*)message { UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:@"" message:message delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [myAlert show]; [myAlert release]; } -(void)unzip { NSString *sourcepath = [[NSBundle mainBundle] pathForResource:@"secret" ofType:@"zip"]; NSString*filename = @"secret.txt"; NSArray *docPaths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *destinationpath = [docPaths objectAtIndex: 0]; if (filename != nil ) destinationpath = [destinationpath stringByAppendingPathComponent: filename]; ZipArchive* za = [[ZipArchive alloc] init]; if( [za UnzipOpenFile:sourcepath Password:@""] ) { BOOL ret = [za UnzipFileTo:destinationpath overWrite:YES]; if( NO==ret ) [self alert:@"Problem"]; else [self alert:@"Success"]; [za UnzipCloseFile]; } [za release]; NSString *test = [[NSString alloc] initWithContentsOfFile:destinationpath encoding:NSASCIIStringEncoding error:nil]; [self alert:test]; }

    Read the article

1