NSFileManager 是一个对文件进行操作的类
可以创建文件夹,移动文件夹,复制文件夹等.
// 创建文件
- (void)createFile
{
// 获取Documents文件路径
#define kDocumentsPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]
// 拼接路径
NSString *filePath = [kDocumentsPath stringByAppendingPathComponent:@"Download"];
NSLog(@"%@",filePath);
// 获取 操作文件对象
NSFileManager *fileManger = [NSFileManager defaultManager];
// withIntermediateDirectories
// YES 如果不存在 创建 可以覆盖 反之 不可以覆盖(创建失败)
BOOL isCreateFile = [fileManger createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
NSLog(@"%d",isCreateFile);
}
// 移动
- (void)moveFile
{
// 拼接老路径
NSString *old = [kDocumentsPath stringByAppendingPathComponent:@"Download"];
// 拼接新路径
NSString *new = [kCachesPath stringByAppendingPathCo