Using the C FILE type:int getFileSizeFromPath(char * path)
{
FILE * file;
int fileSizeBytes = 0;
file = fopen(path,"r");
if(file>0){
fseek(file, 0, SEEK_END);
fileSizeBytes = ftell(file);
fseek(file, 0, SEEK_SET);
fclose(file);
}
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];
}
|