开发者

Get file property

开发者 https://www.devze.com 2022-12-23 05:00 出处:网络
H开发者_高级运维ow to get file size of pdf,gif,doc etc using xcode. suppose to i get pdf file form resorce folder so how can i get size of for this file.

H开发者_高级运维ow to get file size of pdf,gif,doc etc using xcode. suppose to i get pdf file form resorce folder so how can i get size of for this file.

is there any way?

Thanks you,


If you want to calculate the size of your resource file in run-time basically you can do the following (omitting error checks etc):

// Get path for resource file
NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"myPDFFile" ofType:@"pdf"];
// Get file attributes
NSDictionary* attributeDict = [[NSFileManager defaultManager] attributesOfItemAtPath:resourcePath error:nil];
// Get size attribute
NSNumber* fileSizeObj = [attributeDict objectForKey:NSFileSize];
long long fileSizeVal = [fileSizeObj lonLongValue];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号