应用程序的文件夹在iPhone中

时间:2011-05-23 06:02:08

标签: iphone dropbox

我正在使用Dropbox API并在应用程序文档文件夹中下载文件。

我能够从文档目录中查看表格中的文件列表。如何从此表格视图中读取照片或文件?

那iPhone怎么样?我们可以直接访问文档文件夹吗?

2 个答案:

答案 0 :(得分: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;

答案 1 :(得分:0)

这是获取文档目录的更常用方法 -

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

NSString *filePath = [documentsDirectory stringByAppendingPathComponent:fileName];

您可以使用NSFileManager检查目录的内容。您可以查看contentsOfDirectoryAtPath:error:方法。