zoukankan      html  css  js  c++  java
  • Document

    1     //  在Documents目录下创建一个名为LaunchImage的文件夹
     2     NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"LaunchImage"];
     3     NSLog(@"%@",path);
     4     
     5     NSFileManager *fileManager = [NSFileManager defaultManager];
     6     BOOL isDir = FALSE;
     7     BOOL isDirExist = [fileManager fileExistsAtPath:path isDirectory:&isDir];
     8     if(!(isDirExist && isDir))
     9         
    10     {
    11         BOOL bCreateDir = [fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    12         if(!bCreateDir){
    13             NSLog(@"创建文件夹失败!");
    14         }
    15         NSLog(@"创建文件夹成功,文件路径%@",path);
    16     }
    17     
    18     UIImage *image=[UIImage imageWithContentsOfFile:@"testimage.png"];
    19     NSData *data = UIImagePNGRepresentation(image);
    20     //将testimage.png保存到LaunchImage文件夹下,新名称为image1.png
    21          BOOL isSaved=   [fileManager createFileAtPath:[path stringByAppendingString:@"/image1.png"] contents:data attributes:nil];
    22     NSLog(@"图片保存状态:%d",isSaved);
    23     
    24     //获取保存的图片
    25     UIImage *newimage=[UIImage imageWithContentsOfFile:[path stringByAppendingString:@"/image1.png"]];
    26    
    27 //   删除文件
    28      BOOL isDelete=[fileManager removeItemAtPath:path error:nil];
    29     NSLog(@"%d",isDelete);
  • 相关阅读:
    模拟100 题解
    模拟99 题解
    模拟98 题解
    模拟97 题解
    模拟96 题解
    模拟95 题解
    模拟94 题解
    模拟93 题解
    模拟92 题解
    Django-- 多数据库联用
  • 原文地址:https://www.cnblogs.com/meakelra/p/4073800.html
Copyright © 2011-2022 走看看