获取文件属性

- (NSString *) getCompletePath{	
	return [[NSBundle mainBundle] pathForResource:@"test" ofType:@"plist"];
}

NSFileManager * filemanager = [[NSFileManager alloc] init];
if([filemanager fileExistsAtPath:[self getCompletePath] isDirectory:false]){		
	NSDictionary * attributes = [filemanager attributesOfItemAtPath:[self getCompletePath] error:nil];
	[filemanager release];
	NSNumber *FileSize = [attributes objectForKey:NSFileSize];
	NSLog(@"%@", attributes);
	NSLog(@"%d", [FileSize intValue]);
}

 

输出结果:

 

2011-10-29 19:56:31.377 File[3751:b603] {
    NSFileCreationDate = "2011-10-29 05:50:01 +0000";
    NSFileExtensionHidden = 0;
    NSFileGroupOwnerAccountID = 20;
    NSFileGroupOwnerAccountName = staff;
    NSFileModificationDate = "2011-10-29 05:50:01 +0000";
    NSFileOwnerAccountID = 501;
    NSFileOwnerAccountName = gaohf;
    NSFilePosixPermissions = 420;
    NSFileReferenceCount = 1;
    NSFileSize = 42;
    NSFileSystemFileNumber = 11429545;
    NSFileSystemNumber = 234881026;
    NSFileType = NSFileTypeRegular;
}
2011-10-29 19:56:31.378 File[3751:b603] 42
 

你可能感兴趣的:(ios,iPhone,文件属性)