/// 获取路径下所有文件名
- (NSArray *)allFilesAtPath:(NSString *)dirString {// 初始长度给个3
NSMutableArray* array = [NSMutableArray arrayWithCapacity:3];
NSFileManager* fileMgr = [NSFileManager defaultManager];
NSArray* tempArray = [fileMgr contentsOfDirectoryAtPath:dirString error:nil];
for (NSString* fileName in tempArray) {
BOOL flag = YES;
NSString* fullPath = [dirString stringByAppendingPathComponent:fileName];
if ([fileMgr fileExistsAtPath:fullPath isDirectory:&flag]) {
if (!flag) {
[array addObject:fullPath];
}
}
}
return array;
}
转载于:https://my.oschina.net/codeismygirl/blog/647619