Is there anyway I can look at the size of a file the application creates in bytes then store that number to use later? OR is there any way I can tell if an object in an NSArray is empty, I've tried everything, but it just doesn't work!
Asked
Active
Viewed 4,704 times
1 Answers
22
Use NSFileManager class' method
- (NSDictionary *)attributesOfItemAtPath:(NSString *)path error:(NSError **)error
The size key in the returned dictionary is defined as
NSString * const NSFileSize;
So for an example
NSError *error = nil;
NSDictionary *attributes = [[NSFileManager defaultManager]
attributesOfItemAtPath:@"/path/to/file" error:&error];
if (!error) {
NSNumber *size = [attributes objectForKey:NSFileSize];
}

nduplessis
- 12,236
- 2
- 36
- 53
-
nduplessis it works well.But a small doubt when the file was in documents directory its size was 32 mb but when i transferred the file to ftp successfully the same file size was 38 mb.How's it possible? FYI: FTP is in 2003 server which is 64 bit system. – Durai Amuthan.H Feb 14 '14 at 21:27