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;

    }

  • 相关阅读:
    死锁
    信号量
    实现临界区互斥的基本方法
    进程同步的基本概念:临界资源、同步和互斥
    操作系统典型调度算法
    [ 转]Collections.unmodifiableList方法的使用与场景
    【转】Android Support v4、v7、v13的区别和应用场景
    [转]finished with non-zero exit value 2
    [转]Git远程操作详解
    [转] git fetch与pull
  • 原文地址:https://www.cnblogs.com/supper-Ho/p/6187629.html
Copyright © 2011-2022 走看看