Created
April 15, 2012 10:07
-
-
Save yeahq/2391678 to your computer and use it in GitHub Desktop.
Delete File
This file contains 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
NSString *path; | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
path = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"SomeDirectory"]; | |
path = [path stringByAppendingPathComponent:@"SomeFileName"]; | |
NSError *error; | |
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) //Does file exist? | |
{ | |
if (![[NSFileManager defaultManager] removeItemAtPath:path error:&error]) //Delete it | |
{ | |
NSLog(@"Delete file error: %@", error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment