Two functions to get the filesize. One using old school file pointers, the other using the NSFileManager object in Xcode.


Using the C FILE type:

int getFileSizeFromPath(char * path)
    FILE * file;
    int fileSizeBytes = 0;
    file = fopen(path,"r");
        fseek(file, 0, SEEK_END);
        fileSizeBytes = ftell(file);
        fseek(file, 0, SEEK_SET);
    return fileSizeBytes;

or in XCode use the NSFileManager:

NSFileManager * filemanager = [[NSFileManager alloc]init];
if([filemanager fileExistsAtPath:[self getCompletePath] isDirectory:&isDirectory]){

    NSDictionary * attributes = [filemanager attributesOfItemAtPath:[self getCompletePath] error:nil];

// file size
    NSNumber *theFileSize;
     if (theFileSize = [attributes objectForKey:NSFileSize])_fileSize= [theFileSize intValue];