views:

37

answers:

1

I have stored the videos in the documents folder. the path is

/Users/sridhar/Library/Application Support/iPhone Simulator/User/Applications/EC177E77-8665-485C-93DE-62350FA6D0E7/Documents/air.mp4   

I want to delete the video . How can I do it programmatically.

+1  A: 

It should work:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"air.mp4"];
BOOL succeed = [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
Vladimir
You don't have to make two strings, do you? Can't you just use this when getting the path?`NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];`
Emil
Yes you can. The variant you choose I think depends on what level of readability you want to get... It may be useful to see each step just for learning purposes
Vladimir
Thank You Vladimir. It's was working fine. Thank you for posting the code in more readability.
srikanth rongali