I have a path to file contained in an NSString. Is there a method to get its file size?
+3
A:
See sample code in FileManager's fileAttributesAtPath:traverseLink: documentation
thesamet
2009-05-02 19:45:37
Thanks for the link!
hekevintran
2009-05-02 20:59:35
+3
A:
Bear in mind that fileAttributesAtPath:traverseLink: is deprecated as of Mac OS X v10.5. Use attributesOfItemAtPath:error: instead, described at the same URL thesamet mentions.
With the caveat that I'm an Objective-C newbie, and I'm ignoring errors that might occur in calling attributesOfItemAtPath:error:, you can do the following:
NSString *yourPath = @"Whatever.txt";
NSFileManager *man = [[NSFileManager alloc] init];
NSDictionary *attrs = [man attributesOfItemAtPath: yourPath error: NULL];
UInt32 result = [attrs fileSize];
Frank Shearar
2009-11-10 12:54:54