在ios中的Document中创建多级文件夹以及文件
来源:互联网 发布:mac删除空白页 编辑:程序博客网 时间:2024/06/06 06:51
- - (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++
- 实现十进制与压缩bcd码之间的转换
- windows异常处理(pure function、invalid call、seh)
- 让类做HashMap的键-容器深入研究
- SQL SERVER 特殊需求的一个替换实例 --【叶子】
- SQL获得固定长度的随机字符串
- 在ios中的Document中创建多级文件夹以及文件
- 有没有pdf格式怎么转换成txt格式
- SQL SERVER 如何处理带字母的自增列--【叶子】
- 最短路径算法(floyd算法)
- HashMap的内部实现-容器深入研究
- SQL SERVER 2000/2005/2008 一句话完成分组后加序号--【叶子】
- EXCEL公式 1 两列数据之间的判断和求和
- Nginx+Tomcat+memcached负载均衡实现session共享
- 【武汉】关于秒秒购