2010-08-10 5 views
0

je suis nouveau pour iPhone programming..can quelqu'un me aider à sortir du problème suivantDésarchivage le fichier zip ne fonctionne pas

je suis en utilisant le code à unarcive un vide sanitaire fichier zip .. sa ne fonctionne pas ... et imprimer le 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 ....

Répondre

0

je suis la solution ...

le problème est le fichier zip n'est pas reconnu ... i changé le code de mise en jachère

NSString *updateURL = [[NSBundle mainBundle] pathForResource:@"bmlg" ofType:@"zip" inDirectory:@"res"]; 

this helped me

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] pathForResource:@"bmlg" ofType:@"zip" inDirectory:@"res"]; 


[fileManager createDirectoryAtPath:filePath withIntermediateDirectories:NO attributes:nil error:nil]; 


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

    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]; 
+0

Je pense que cela peut ne pas possible sur l'appareil. – ajay

+0

je l'ai utilisé en mai application et fonctionnant avec succès sur mon appareil aussi – rockey

+0

télécharger le dossier "ZipArchive" opensource, vous aurez le dossier minizip et les fichiers ZipArchive vous devez importer le "ZipArchive.h" – rockey

Questions connexes