title: Easy way to get size of folder (ObjC/Cocoa)?
body: <p>Right now I'm using this code to get the size of a folder:</p>
  
  <pre><code>NSArray *contents;
          NSEnumerator *enumerator;
          NSString *path;
          contents = [[NSFileManager defaultManager] subpathsAtPath:folderPath];
          enumerator = [contents objectEnumerator];
          while (path = [enumerator nextObject]) {
              NSDictionary *fattrib = [[NSFileManager defaultManager] fileAttributesAtPath:[folderPath stringByAppendingPathComponent:path] traverseLink:YES];
              fileSize +=[fattrib fileSize];
          }
  
          [contents release];
          [path release]; 
  </code></pre>
  
  <p>The problem is that its highly innacurate. It either adds a few megabytes or deducts a few megabytes from the actual size. For example I got the file size of an .app bundle and this method reported 16.2MB, whereas the actual thing is 15.8. </p>
  
  <p>What's the best way to get the size of a folder?</p>
  
  <p>Thanks</p>