2011-05-23 73 views
0

我正在使用Dropbox API並將文件下載到應用程序文檔文件夾中。iPhone中的應用程序的文檔文件夾

我能夠從文檔目錄查看錶中的文件列表。我如何從這個表格視圖中讀取照片或文件?

那麼iPhone呢?我們可以直接訪問文件夾嗎?

+0

應用程序文檔文件夾是SandBox的一部分。所以你不能直接放入任何物品。您可以先將文件添加到xCode proj(NSbundle)。那麼只能訪問 – iOSPawan 2011-05-23 06:13:38

回答

0

這是比較常用的方法來獲得文件目錄 -

NSArray *searchResults = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [searchResults objectAtIndex:0]; 

NSString *filePath = [documentsDirectory stringByAppendingPathComponent:fileName]; 

您可以使用NSFileManager檢查目錄的內容。您可以查看contentsOfDirectoryAtPath:error:方法。

+0

行。我不能訪問文件目錄沒有代碼在iPhone – iProgrammer 2011-05-23 07:58:59

+1

號。看看[這](http://iphone-dev-tips.alterplay.com/2010/11/file-sharing-from-app-to-itunes-is-too.html)。 – 2011-05-23 08:01:46

+0

好..如果我想上傳照片到dropbox.I應該使用imagepicker或我可以保存圖像從相機到文檔文件夾? – iProgrammer 2011-05-23 08:09:52

0

訪問的文件夾 -

NSDictionary *theCatalogInfo=nil; 
NSString *theCatalogFilePath = [NSString stringWithFormat:@"%@/Documents/",NSHomeDirectory()]; 
theCatalogFilePath = [theCatalogFilePath stringByAppendingString:@"File Name"]; 
if(nil!=theCatalogFilePath) 
{ 


    theCatalogInfo=[[NSDictionary alloc]initWithContentsOfFile:theCatalogFilePath]; 

} 

return theCatalogInfo; 
相關問題