比如获取后缀为xml的所有文件
NSFileManager *fileManager = [NSFileManagerdefaultManager];
NSDirectoryEnumerator *myDirectoryEnumerator = [fileManagerenumeratorAtPath:baseSavePath]; //baseSavePath 为文件夹的路径
NSMutableArray *filePathArray = [[NSMutableArrayalloc]init]; //用来存目录名字的数组
NSString *file;
while((file=[myDirectoryEnumeratornextObject])) //遍历当前目录
{
if([[filepathExtension] isEqualToString:@"xml"]) //取得后缀名为.xml的文件名
{
[filePathArray addObject:[baseSavePath stringByAppendingPathComponent:file]];//存到数组
}
}