// 判断文件夹是否存在,不存在则创建对应文件夹 NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *path = @"/Users/apple/Desktop/导出路径/嘻嘻"; BOOL isDir = FALSE; BOOL isDirExist = [fileManager fileExistsAtPath:path isDirectory:&isDir]; if(!(isDirExist && isDir)) { BOOL bCreateDir = [fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; if(!bCreateDir){ NSLog(@"创建失败!"); } NSLog(@"创建成功!"); NSLog(@"%@",path); }else { NSLog(@"已经有该文件夹!"); }
时间: 2024-11-06 18:03:05