开发者

Get file property

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜