iOS 获取沙盒Documents文件夹下所有的文件
2017-08-23 本文已影响259人
彗星来的那一夜
-
(NSArray *) getAllFileNames:(NSString *)dirName
{
// 获得此程序的沙盒路径
NSArray *patchs = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);// 获取Documents路径
// [patchs objectAtIndex:0]
NSString *documentsDirectory = [patchs objectAtIndex:0];
NSString *fileDirectory = [documentsDirectory stringByAppendingPathComponent:@"%@", dirName];NSArray *files = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath:fileDirectory error:nil];
return files;
}