zoukankan      html  css  js  c++  java
  • 获取文件属性

    //

    //  main.m

    //  02-获取文件属性

    //

    //  Created by apple on 14-3-21.

    //  Copyright (c) 2014年 apple. All rights reserved.

    //

    #import <Foundation/Foundation.h>

    int main(int argc, const char * argv[])

    {

        @autoreleasepool {

            

            /*

            NSString * str = @"www.itcast.cn";

            NSError * error;

            BOOL isWriteSuccess = [str writeToFile:@"/Users/aplle/Desktop/test.txt" atomically:YES encoding:NSUTF8StringEncoding error:&error];

            if (isWriteSuccess)

            {

                NSLog(@"创建成功");

            }

            else

            {

                NSLog(@"error %@",error);

            }

             */

            

            //1.获取文件管理器

            NSFileManager * fileManager = [NSFileManager defaultManager];

            NSString * path = @"/Users/aplle/Desktop/test.txt";

            NSError * error;

            NSDictionary * dic = [fileManager attributesOfItemAtPath:path error:&error];

        

            

            NSLog(@"dic %@",dic);

            

            if (error == nil)

            {

               NSDate * date = [dic objectForKey:NSFileCreationDate];

                NSString * size = [dic objectForKey:NSFileSize];

                NSLog(@" date = %@, size = %@",date,size);

            }

        }

        return 0;

    }

  • 相关阅读:
    linux C++类中成员变量和函数的使用
    使用linux backtrace打印出错函数堆栈信息
    R String 操作
    make
    *.efasta to fasta format transformation
    python os 库
    Ch12 Resampling statistics and bootstrapping
    Updating an R installation
    10 步让你成为更优秀的程序员
    Working with large datasets
  • 原文地址:https://www.cnblogs.com/supper-Ho/p/6187629.html
Copyright © 2011-2022 走看看