我要知道我的Resources文件夹的每个子文件夹中有多少图像。我发现了这个:
NSMutableString* bundlePath = [NSMutableString stringWithCapacity:4];
[bundlePath appendString:[[NSBundle mainBundle] bundlePath]];
[bundlePath appendString:@"/MyFolder"];
NSArray *directoryContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundlePath error:nil];
int numberOfFileInFolder = [directoryContent count];
和此:
int pants = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/your/path/here" error:NIL] count];
最好的方法是什么?
解决方案:
int numberOfFileInFolder = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"/Angry"] error:Nil] count];
复制文件时要注意!!!不要忘记选中“为任何添加的文件夹创建文件夹引用”