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 direct开发者_如何学编程ly?
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.
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;
精彩评论