在d:\下创建文件夹

&&&&&&&&&&&&&&&&&&
posts - 42,comments - 6,trackbacks - 0
沙盒下主要有四个文件夹:document,caches,tmp,library
document 的路径 程序运行时生成的文件,这个文件不要存比较放大的文件,比如音频,视频类,因为这里的东西会被上传
caches 的路径 一般用于文件的下载,存储(不会被上传)
tmp 临时文件.程序结束后应该清空
沙盒文件夹路径获取:
获取沙盒路径:
1 NSString *sandBoxPath = NSHomeDirectory();
获取 document :
1 NSString *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
获取 caches 路径:
1 NSString *cacherPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
获取 tmp 路径:
1 NSString *tmpPath = NSTemporaryDirectory();
在沙盒下创建文件:
1.获取路径
2.拼接文件名(包括后缀)
3.将内容写到文件
例:写一个 txt 文件:
1 //NSString 写入
NSString *str = @"二傻子";
//获取 document 路径
NSString *docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
//拼接上一个 txt 文件
NSString *filePath = [docPath stringByAppendingPathComponent:@"coco.txt"];
//吧字符串写到 txt 文件
[str writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
例:写一个 array 文件:
1 //NSArray
NSArray *array = @[@"二傻子",@"三傻子",@"翠花",@"叶良岑",@"赵日天",@"王尼玛"];
NSString *tmpPath1 = NSTemporaryDirectory();
NSString *tmpFilePath = [tmpPath1 stringByAppendingPathComponent:@"tmp.plist"];
[array writeToFile:tmpFilePath atomically:YES];
例:写一个 dictionary 文件:
1 NSDictionary *dic = @{@"1号":@"XXXXX",@"2号":@"XXXXX",@"3号":@"XXXXX",@"4号":@"XXXXX",@"5号":@"XXXXX"};
3 NSString *dicPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
4 NSString *dicFilePath = [dicPath stringByAppendingPathComponent:@"dic.plist"];
6 [dic writeToFile:dicFilePath atomically:YES];
例:写一个 image 文件:
1 NSString *cacherPath2 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
3 NSString *imgFilePath = [cacherPath2 stringByAppendingPathComponent:@"123.png"];
4 5 NSData *data = [[NSData alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1" ofType:@"png"]];
7 [data writeToFile:imgFilePath atomically:YES];
阅读(...) 评论()温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_',
blogTitle:'请使用命令行展开功能来完成以下练习:(一)创建/tmp目录下的:a_c,a_d,b_c,d_d
(2)创建/tmp/mylinux目录下的;',
blogAbstract:'\r\n创建/tmp目录下的:a_c, a_d, b_c, b_d[root@localhost tmp]# mkdir {a,b}_{c,d}\r\n\r\n创建/tmp/mylinux目录下的:&[root@localhost tmp]# mkdir -p mylinux/{bin,boot/grub,dev,etc/{rc.d/init.d,sysconfig/network-scripts},lib/modules,',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:3,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}}

我要回帖

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信