How do I delete a file from documents directory? - IPhone | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

How do I delete a file from documents directory? - IPhone

Tuesday

iPhone sdk – Delete Files in the Documents Directory:
                                           This id the code for delete files from iphone's  Documents directory. In this example I've deleting a file from document's sub directory in iPhone (media_1). I'm using this code to delete an image from the media_1 directory and it,'s works well.

// Get the Documents directory path
NSString *temPath = [NSString stringWithFormat:@"%@%d",@"Documents/Media_", Key_mediaID];
//This temPath look line ../../../Documents/Media_1

 NSString *documentsDirectoryPath = [NSHomeDirectory() stringByAppendingPathComponent:temPath];

// Delete the file using NSFileManager
 NSFileManager *fileManager = [NSFileManager defaultManager];
 [fileManager removeItemAtPath:[documentsDirectoryPath stringByAppendingPathComponent:Your File Name] error:nil];

0 comments:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets