2015-01-21 61 views
1

我正在下載一個zip文件並保存在文檔目錄中。然後使用ssziparchive進行解壓縮。但沒有從zip文件獲取任何數據。如何獲取數據。我無法看到我的解壓縮文件在哪裏。在文檔目錄中,只有我得到了這個。 enter image description here從壓縮文件無法從文檔目錄中獲取數據

我已經使用這個代碼,以使拉鍊爲未壓縮文件

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

郵編數據存儲在捆如下文檔目錄。

  1. 從Bundle獲取路徑。在文檔目錄

    NSString *StrZIP = [[NSBundle mainBundle] pathForResource:@"TestZIP" ofType:@"zip"]; 
    
  2. 轉換ZipNSData

    NSData *ZIPData = [NSData dataWithContentsOfFile:StrZIP]; 
    
  3. 商店Zip文件

    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 
    
  4. TeztZIP是解壓在documentsPath

    使用

OUTPUT:

enter image description here

+0

不工作我已經嘗試了本 – Sport 2015-01-21 07:16:29

+0

它的工作,我在我的項目,可能你的代碼有一些錯誤。檢查你的代碼。 – 2015-01-21 07:32:08

+0

我的zip文件庫內 – Sport 2015-01-21 08:19:37