I am working for my next iPhone application which will create an audio file and save it in the Documents directory. I also created a table view which listed all the audio files such that user can delete them. Please note that the Documents directory is the only place where you can store your application files.
// Get the Documents directory path NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [paths objectAtIndex:0]; // Delete the file using NSFileManager NSFileManager *fileManager = [NSFileManager defaultManager]; [fileManager removeItemAtPath:[documentsDirectoryPath stringByAppendingPathComponent:yourFile.txt] error:nil];
If your file is located in a sub folder inside the Documents folder, you just need to append one more PathComponent.
Done =)
Reference: How do I delete a file in my documents directory?
