//创建文件管理对象
NSFileManager *fileManger = [NSFilemanager defaultManger];
//找到沙盒路径
NSArray *path = NSSearchPathForDirectoriesInDomain(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *documentDirectory = [path objectAtIndex:0];
// 把文件夹下面的 文件放到数组里面
NSArray *contents = [fileManager contentOfDirectoryAtPath:documentsDirectory error:NULL];
// 创建遍历路径对象
NSEnumerator *e = [contents objectEnumerator];
NSString *fileName;
while ((fileName = [e nextObject])){
[fileManager removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:filename] error:NULL];
}
网友评论