Created
November 23, 2016 01:54
-
-
Save SongJiaqiang/289d59204efb5fe3a293574a8cbc1c52 to your computer and use it in GitHub Desktop.
delete file from document directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)removeFile:(NSString *)filename | |
{ | |
NSFileManager *fileManager = [NSFileManager defaultManager]; | |
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; | |
NSString *filePath = [documentsPath stringByAppendingPathComponent:filename]; | |
NSError *error; | |
BOOL success = [fileManager removeItemAtPath:filePath error:&error]; | |
if (success) { | |
UIAlertView *removedSuccessFullyAlert = [[UIAlertView alloc] initWithTitle:@"Congratulations:" message:@"Successfully removed" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:nil]; | |
[removedSuccessFullyAlert show]; | |
} | |
else | |
{ | |
NSLog(@"Could not delete file -:%@ ",[error localizedDescription]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment