Application's Document folder in iphone

空扰寡人 提交于 2019-12-12 06:23:55

问题


I am using dropbox API and downloading file in application document folder.

I am able to view list of files in table from document directory. How can I read photos or file from this table view?

And what about the iPhone. Can we access document folder directly?


回答1:


This is the more commonly used approach to get the documents directory –

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

NSString *filePath = [documentsDirectory stringByAppendingPathComponent:fileName];

You can use NSFileManager to examine the contents of the directory. You can look at the contentsOfDirectoryAtPath:error: method.




回答2:


Access document Folder -

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


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

}

return theCatalogInfo;


来源:https://stackoverflow.com/questions/6093389/applications-document-folder-in-iphone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!