【发布时间】:2013-11-29 23:21:35
【问题描述】:
我在文档目录的一个文件夹中保存了许多文件。这是其中之一的路径:
/var/mobile/Applications/120FD973-C902-405E-A645-B1651904CE9B/Documents/1127029/BusinessCard2258009241.card
我想列出文件夹(1127029)中的文件,我试过这个:
NSFileManager *fManager = [NSFileManager defaultManager];
NSString *item;
NSArray *contents = [fManager contentsOfDirectoryAtPath:[NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/%d", FolderNumber]] error:nil];
// >>> this section here adds all files with the chosen extension to an array
for (item in contents){
if ([[item pathExtension] isEqualToString:@"card"]) {
...
但它不起作用
【问题讨论】:
-
你调试过你的代码吗?你确认你的路径是正确的吗?分解您的代码,以便您真正看到您正在访问的路径的值。并搜索如何正确访问
Documents文件夹。 -
兄弟不太确定,但它应该类似于 [NSString stringWithFormat:@"Documents/%d", documentsDirectory]] error:nil];
-
这里可以参考link
-
解决了???得到你要找的东西
-
为什么我被否决了?在我看来这是一个合理的问题......
标签: ios