在ios中的Document中创建多级文件夹以及文件
来源:互联网 发布:怎么下载淘宝app 编辑:程序博客网 时间:2024/06/05 23:00
- (NSString *)dataPath:(NSString *)file{ NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"badge"]; BOOL bo = [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; NSAssert(bo,@"创建目录失败"); NSString *result = [path stringByAppendingPathComponent:file]; return result; } - (void)viewDidLoad{ [super viewDidLoad]; //此处首先指定了图片存取路径(默认写到应用程序沙盒 中) NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); //并给文件起个文件名 NSString *imageDir = [[[paths objectAtIndex:0] stringByAppendingPathComponent:@"163"] stringByAppendingPathComponent:@"songzi"]; //存放图片的文件夹 NSString *imagePath =[imageDir stringByAppendingPathComponent:@"0.png"]; NSData *data = nil; //检查图片是否已经保存到本地 if([self isExistsFile:imagePath]){ data=[NSData dataWithContentsOfFile:imagePath]; }else{ data = [NSData dataWithContentsOfURL:[NSURL URLWithString: @"http://211.154.154.96:7071/press/163/songzi/0.jpg"]]; //创建文件夹路径 [[NSFileManager defaultManager] createDirectoryAtPath:imageDir withIntermediateDirectories:YES attributes:nil error:nil]; //创建图片 [UIImagePNGRepresentation([UIImage imageWithData:data]) writeToFile:imagePath atomically:YES]; } imageView.image = [UIImage imageWithData:data];}
0 0
- 在ios中的Document中创建多级文件夹以及文件
- 在ios中的Document中创建多级文件夹以及文件
- 在ios中的Document中创建多级文件夹以及文件
- 在ios中的Document中创建多级文件夹以及文件
- 在ios中的Document中创建多级文件夹以及文件
- 针对含有多级文件夹时,文件创建
- 创建多级文件夹/目录下的文件
- ios如何在xcode中创建文件夹
- linux c创建文件夹,并在文件夹中创建文件
- iOS在沙盒Documents中创建文件夹以及获取沙盒路径
- java创建多级目录以及文件
- 在VS2010中添加多级文件夹
- 在ASP中自动创建多级文件夹的函数(使用FSO)
- 在ASP中自动创建多级文件夹的函数(使用FSO)
- 创建多级文件夹
- vb 创建多级文件夹
- 创建多级文件夹
- 创建多级文件夹vc++
- 《樊江关》_0
- 栈的顺序存储结构的实现
- JAXP解析XML
- uml类图中得集中重要的逻辑关系和实现
- cocos2d-x使用python脚本创建项目的简单方法
- 在ios中的Document中创建多级文件夹以及文件
- MYSQL explain详解
- HDOJ 1281 棋盘游戏
- 感知机学习python 神经网络设计教材P43
- 安装Node.js
- window环境下,php环境拓展memcached
- javac 编译带有package的类
- 关于Android apk签名问题
- UIView生命周期