How to get the file size given a path?

后端 未结 10 1195
自闭症患者
自闭症患者 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:56

    This one liner can help people:

    unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:someFilePath error:nil] fileSize];
    

    This returns the file size in Bytes.

提交回复
热议问题