-(void)removeFileByPath:(NSString*)path{
NSFileManager *fm = [NSFileManager defaultManager];
if (![fm fileExistsAtPath:path]) {
NSLog(@"no file");
return;
}
NSError *error=nil;
[fm removeItemAtPath:path error:&error];
if (error!=nil) {//failed
NSLog(@"failed to remove %@",[error localizedDescription]);
}else{
NSLog(@"Successfully removed:%@",path);
}
}
NSString* path=[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
path=[path stringByAppendingPathComponent:@"test.png"];
[self removeFileByPath:path];