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.
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];
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...