IOS获取文件属性

来源:互联网 发布:php用什么服务器 编辑:程序博客网 时间:2024/06/06 09:11

    NSDictionary *attributes = [[NSFileManagerdefaultManager] attributesOfItemAtPath:patherror:nil];

   if (attributes != nil) {

       NSNumber *fileSize = [attributes objectForKey:NSFileSize];

       NSString *accountName = [attributes objectForKey:NSFileOwnerAccountName];

       NSString *createDate = [attributes objectForKey:NSFileCreationDate];

       NSDate *modifyDate = [attributes objectForKey:NSFileModificationDate];

       //文件大小

       if (fileSize) {

           NSLog(@"File size: %qi\n", [fileSizeunsignedLongLongValue]);

        }

       //文件创建日期

       if (createDate) {

           NSLog(@"File creationDate: %@\n", createDate);

            //textField.text=NSFileCreationDate;

        }

       //文件所有者

       if (accountName) {

           NSLog(@"Owner: %@\n", accountName);

        }

       //文件修改日期

       if (modifyDate) {

           NSLog(@"Modification date: %@\n", modifyDate);

        }

    }

0 0