作品链接:http://www.jianshu.com/users/1e0f5e6f73f6/top_articles
+ (void)deleteFiles:(NSString *)path;{
// 1. 判断文件还是目录
NSFileManager * fileManger = [NSFileManager defaultManager];
BOOL isDir = NO;
BOOL isExist = [fileManger fileExistsAtPath:pathisDirectory:&isDir];
// 2. 判断是不是目录
if (isExist) {
if (isDir) {
NSArray * dirArray = [fileMangercontentsOfDirectoryAtPath:path error:nil];
NSString * subPath = nil;
for (NSString * str in dirArray) {
subPath = [pathstringByAppendingPathComponent:str];
BOOL issubDir = NO;
[fileManger fileExistsAtPath:subPath isDirectory:&issubDir];
[self deleteFiles:subPath];
}
}else{ NSLog(@"%@",path);
[manager removeItemAtPath:filePath error:nil];
}
}else{
NSLog(@"你打印的是目录或者是不存在 ");
}
}