我想从我的应用程序文档目录中删除一个图像。我编写的删除图像代码是:
-(void)removeImage:(NSString *)fileName
{
fileManager = [NSFileManager defaultManager];
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentsPath = [paths objectAtIndex:0];
filePath = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", fileName]];
[fileManager removeItemAtPath:filePath error:NULL];
UIAlertView *removeSuccessFulAlert=[[UIAlertView alloc]initWithTitle:@"Congratulation:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil];
[removeSuccessFulAlert show];
}
部分起作用了。这段代码从目录中删除文件,但是当我检查目录中的内容时,它仍然显示图像名。我要从目录中完全删除该文件。我应该在代码中改变什么来做同样的事情?谢谢