iOS--删除文件

+ (void)removeDataBase:(NSString*)name{

NSString* cachePath = [NSString stringWithFormat:@"/%@",[NSString stringWithFormat:@"/%@/%@",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject],name]];

NSFileManager*fileManager = [NSFileManager defaultManager];

if (![fileManager fileExistsAtPath:cachePath]) {

return;

}

NSEnumerator* chileFilesEnumerator = [[fileManager subpathsAtPath:cachePath]objectEnumerator];

NSString* fileName;

while ((fileName = [chileFilesEnumerator nextObject]) !=nil) {

NSString* fileAbsolutePath = [cachePath stringByAppendingPathComponent:fileName];

[fileManager removeItemAtPath:fileAbsolutePath error:NULL];

}

}

你可能感兴趣的:(iOS--删除文件)