How to get the file size given a path?

后端 未结 10 1179
自闭症患者
自闭症患者 2020-11-30 20:22

I have a path to file contained in an NSString. Is there a method to get its file size?

10条回答
  •  無奈伤痛
    2020-11-30 20:54

    Following the answer from Oded Ben Dov, I would rather use an object here:

    NSNumber * mySize = [NSNumber numberWithUnsignedLongLong:[[[NSFileManager defaultManager] attributesOfItemAtPath:someFilePath error:nil] fileSize]];
    

提交回复
热议问题