SHARE
TWEET

File Size With Error Handling

a guest Jan 2nd, 2012 61 Never
  1. NSError *error = nil;
  2.  
  3. //Change YOUR_USERNAME with your username
  4. NSString *path = @"/Users/YOUR_USERNAME/Library/Safari/History.plist";
  5.  
  6. uint64_t fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:path error:&error] fileSize];
  7.  
  8. if (error != nil) {
  9.         NSLog(@"Error: %@", [error localizedDescription]);
  10. } else {
  11.         NSLog(@"File Size: %.0llu", fileSize);
  12. }
RAW Paste Data
Top