如何在我的iPhone应用程序的documents目录内创建目录? [英] How to create an directory inside the documents directory of my iPhone app?
本文介绍了如何在我的iPhone应用程序的documents目录内创建目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将文件存储在documents目录内的特定目录中,这样我就可以遍历所有这些文件并显示给用户选择。
I would like to store files in a specific directory inside the documents directory, so that I can iterate over all these files and show them to the user for selection. Is that possible?
推荐答案
是的,您可以这样做:
NSString *rootString = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0];
self.root = [rootString stringByAppendingPathComponent:@"DirectoryName"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:root isDirectory:YES] == NO)
{
[fileManager createDirectoryAtPath:root attributes:nil];
}
对于检索,您可以执行以下操作:
And For retrieving you can do this:
NSError *error;
NSArray *files = [fileManager contentsOfDirectoryAtPath:root error:&error];
希望这会有所帮助,
谢谢,
Madhup
Thanks, Madhup
这篇关于如何在我的iPhone应用程序的documents目录内创建目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文