objective c iphone delete file
Posted by Eng.Ahmed AlSadiOct 9
xcode – iphone – objective c
Hi;
the method “function” below is an example how to delete file using file manager “NSFileManager” [ NSFileManager : removeItemAtPath: error ] “Removes the file or directory at the specified path.” , you can use this method “function” to do this.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
//exampledb.com
//DeleteFile // By AlSadi
-(void)DeleteFile:(NSString*)filePath
{
NSFileManager* fileMngr = [NSFileManager defaultManager];
if ([fileMngr fileExistsAtPath:filePath]) {
NSError* deletionError;
bool isDeleted = [fileMngr removeItemAtPath:filePath error:&deletionError];
if (isDeleted) {
NSLog(@"file Deleted");
}else {
NSLog(@"Deleting Error : %@",[deletionError localizedDescription]);
}
deletionError = nil;
}
fileMngr = nil;
} |
Related posts:
- Objective-c check if file exists XCode – Objective-C Hi, The simplest way to know or to check if file exists...
- objective c get iTunes file sharing folder files with full path xcode – iphone – objective c Hi; the method “function” below show you how to...
- objective c get iTunes shared document directory files list xcode – iphone – objective c Hi; How to Enable iTunes “folder” file sharing: some...
- objective c UITableView delete all rows table view xcode – iphone – objective c Hi; the example below show how to delete all...
- objective c get or remove file extension from path xcode – iPhone – Objective c if you have file path and want to get...
Leave a Reply