iOS创建、删除文件夹、获取沙盒路径

1.获取沙盒路径

// 获取沙盒路径

NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];

2.创建文件夹

方式一:

// 想在documents目录下创建一个test文件夹

NSString *path = [documentsDirectory stringByAppendingPathComponent:@"test"];


方式二:

// 文件夹创建

NSFileManager *fileManage = [NSFileManager defaultManager];

//先判断这个文件夹是否存在,如果不存在则创建,否则不创建

if (![fileManage fileExistsAtPath:path]) {

    [fileManage createDirectoryAtPath:path attributes:nil];

};


3.删除文件夹

// 文件夹删除

[fileManage removeItemAtPath:path error:nil];

原文地址:https://www.cnblogs.com/miaomiaoshen/p/5188633.html