从文档目录中删除video的问题

我正试图从文档目录中删除一个video,但video并未被删除。

以下是我如何删除video:

//Delete Video NSError *error = nil; //NSData *videoData = [NSData dataWithContentsOfURL:self.finalURL]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"]; [[NSFileManager defaultManager] removeItemAtPath: tempPath error: &error]; UIAlertView *removeSuccessFulAlert=[[UIAlertView alloc]initWithTitle:@"Congratulation:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; [removeSuccessFulAlert show]; 

如果你在你的“ removeItemAtPath ”之后加上一行,你可能会得到一个很好的提示:

 BOOL success = [[NSFileManager defaultManager] removeItemAtPath: tempPath error: &error]; if(!success) { NSLog(@"error from removing item at path %@ is %@", tempPath, [error localizedDescription]); } else { UIAlertView *removeSuccessFulAlert=[[UIAlertView alloc]initWithTitle:@"Congratulation:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; [removeSuccessFulAlert show]; } 

试试这个:

 NSString *tempPath = [documentsDirectory stringByAppendingPathComponent:@"vid1.mp4"];