• 文件操作-图片的拷贝


    - (void)viewDidLoad {

        [super viewDidLoad];

        NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];

        

        NSString *lifeFilePath = [docPath stringByAppendingString:@"Life"];

        NSError *errMsg = nil;

        [[NSFileManager defaultManager]createDirectoryAtPath:lifeFilePath withIntermediateDirectories:YES attributes:nil error:&errMsg];

        

        NSString *WorkFilePath = [docPath stringByAppendingString:@"Work"];

        [[NSFileManager defaultManager]createDirectoryAtPath:WorkFilePath withIntermediateDirectories:YES attributes:nil error:&errMsg];

        NSString *imagePath = [lifeFilePath stringByAppendingString:@"1"];

        if (![[NSFileManager defaultManager]fileExistsAtPath:imagePath]) {

            [[NSFileManager defaultManager]createFileAtPath:imagePath contents:nil attributes:nil];

            NSData *imageData = UIImagePNGRepresentation([UIImage imageNamed:@"1"]);

            [imageData writeToFile:imagePath atomically:YES];

            NSError *errMsg = nil;

            NSString *imagePath2 = [WorkFilePath stringByAppendingPathComponent:@"1"];

            if (![[NSFileManager defaultManager] fileExistsAtPath:imagePath2]) {

                [[NSFileManager defaultManager] copyItemAtPath:imagePath toPath:imagePath2 error:&errMsg];

                if (errMsg) {

                    NSLog(@"%@",errMsg);

                    return;

                }

            }

        };

        

        NSLog(@"%@",lifeFilePath);

    }

  • 相关阅读:
    Win7怎么进入安全模式 三种轻松进入Win7安全模式方法
    Eclipse中新建applet 错误
    经典语录
    轻松一刻
    WIN XP蓝屏代码大全
    大话设计模式简单总结
    生命是闹着玩儿,事事显出如此 (转)
    Educational Codeforces Round 42 (Rated for Div. 2) A
    2018年东北农业大学春季校赛----不完整题解
    POJ
  • 原文地址:https://www.cnblogs.com/yangqinglong/p/5363803.html
Copyright © 2020-2023  润新知