Delete files from Documents folder


/ Published in: Objective C
Save to your folder(s)

Delete the files in Documents folder if it's not a sqlite file.


Copy this code and paste it in your HTML
  1. - (void)deleteFilesFromDocuments {
  2. NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
  3. NSFileManager* fm = [[[NSFileManager alloc] init] autorelease];
  4. NSDirectoryEnumerator* en = [fm enumeratorAtPath:path];
  5. NSError* err = nil;
  6. BOOL res;
  7. NSString* file;
  8. while (file = [en nextObject]) {
  9.  
  10. if ([file rangeOfString:@".sqlite"].location == NSNotFound) {
  11. res = [fm removeItemAtPath:[path stringByAppendingPathComponent:file] error:&err];
  12. if (!res && err) {
  13. NSLog(@"oops: %@", err);
  14. }
  15. }
  16. }
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.