当前位置: 首页 > news >正文

网站的建设的含义自己建网站能赚钱吗

网站的建设的含义,自己建网站能赚钱吗,app网页设计,一流高职院校建设工作网站#xff08;配图的小故事还记得嘛#xff09; NSFileManager是一个单列类#xff0c;也是一个文件管理器。可以通过NSFileManager创建文件夹、创建文件、写文件、读文件内容等等基本功能。 下面将介绍NSFileManager文件操作的十个小功能。我们在Documents里面进行举例#…   配图的小故事还记得嘛     NSFileManager是一个单列类也是一个文件管理器。可以通过NSFileManager创建文件夹、创建文件、写文件、读文件内容等等基本功能。 下面将介绍NSFileManager文件操作的十个小功能。我们在Documents里面进行举例首先是获取Documents的路径。这个在iOS开发之沙盒机制SandBox)已经详细讲解过了。获取Documents路径方法如下 - (NSString *)getDocumentsPath {//获取Documents路径NSArray *paths NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);NSString *path [paths objectAtIndex:0];NSLog(path:%, path);return path; } 创建文件夹 -(void)createDirectory{NSString *documentsPath [self getDocumentsPath];NSFileManager *fileManager [NSFileManager defaultManager];NSString *iOSDirectory [documentsPath stringByAppendingPathComponent:iOS];BOOL isSuccess [fileManager createDirectoryAtPath:iOSDirectory withIntermediateDirectories:YES attributes:nil error:nil];if (isSuccess) {NSLog(success);} else {NSLog(fail);} } 创建文件 -(void)createFile{NSString *documentsPath [self getDocumentsPath];NSFileManager *fileManager [NSFileManager defaultManager];NSString *iOSPath [documentsPath stringByAppendingPathComponent:iOS.txt];BOOL isSuccess [fileManager createFileAtPath:iOSPath contents:nil attributes:nil];if (isSuccess) {NSLog(success);} else {NSLog(fail);} } 写文件 -(void)writeFile{NSString *documentsPath [self getDocumentsPath];NSString *iOSPath [documentsPath stringByAppendingPathComponent:iOS.txt];NSString *content 我要写数据啦;BOOL isSuccess [content writeToFile:iOSPath atomically:YES encoding:NSUTF8StringEncoding error:nil];if (isSuccess) {NSLog(write success);} else {NSLog(write fail);} } 读取文件内容 -(void)readFileContent{NSString *documentsPath [self getDocumentsPath];NSString *iOSPath [documentsPath stringByAppendingPathComponent:iOS.txt];NSString *content [NSString stringWithContentsOfFile:iOSPath encoding:NSUTF8StringEncoding error:nil];NSLog(read success: %,content); } 判断文件是否存在 - (BOOL)isSxistAtPath:(NSString *)filePath{NSFileManager *fileManager [NSFileManager defaultManager];BOOL isExist [fileManager fileExistsAtPath:filePath];return isExist; } 计算文件大小 - (unsigned long long)fileSizeAtPath:(NSString *)filePath{NSFileManager *fileManager [NSFileManager defaultManager];BOOL isExist [fileManager fileExistsAtPath:filePath];if (isExist){unsigned long long fileSize [[fileManager attributesOfItemAtPath:filePath error:nil] fileSize];return fileSize;} else {NSLog(file is not exist);return 0;} } 计算整个文件夹中所有文件大小 - (unsigned long long)folderSizeAtPath:(NSString*)folderPath{NSFileManager *fileManager [NSFileManager defaultManager];BOOL isExist [fileManager fileExistsAtPath:folderPath];if (isExist){NSEnumerator *childFileEnumerator [[fileManager subpathsAtPath:folderPath] objectEnumerator];unsigned long long folderSize 0;NSString *fileName ;while ((fileName [childFileEnumerator nextObject]) ! nil){NSString* fileAbsolutePath [folderPath stringByAppendingPathComponent:fileName];folderSize [self fileSizeAtPath:fileAbsolutePath];}return folderSize / (1024.0 * 1024.0);} else {NSLog(file is not exist);return 0;} } 删除文件 -(void)deleteFile{NSString *documentsPath [self getDocumentsPath];NSFileManager *fileManager [NSFileManager defaultManager];NSString *iOSPath [documentsPath stringByAppendingPathComponent:iOS.txt];BOOL isSuccess [fileManager removeItemAtPath:iOSPath error:nil];if (isSuccess) {NSLog(delete success);}else{NSLog(delete fail);} } 移动文件 - (void)moveFileName {NSString *documentsPath [self getDocumentsPath];NSFileManager *fileManager [NSFileManager defaultManager];NSString *filePath [documentsPath stringByAppendingPathComponent:iOS.txt];NSString *moveToPath [documentsPath stringByAppendingPathComponent:iOS.txt];BOOL isSuccess [fileManager moveItemAtPath:filePath toPath:moveToPath error:nil];if (isSuccess) {NSLog(rename success);}else{NSLog(rename fail);} } 重命名 - (void)renameFileName {//通过移动该文件对文件重命名NSString *documentsPath [self getDocumentsPath];NSFileManager *fileManager [NSFileManager defaultManager];NSString *filePath [documentsPath stringByAppendingPathComponent:iOS.txt];NSString *moveToPath [documentsPath stringByAppendingPathComponent:rename.txt];BOOL isSuccess [fileManager moveItemAtPath:filePath toPath:moveToPath error:nil];if (isSuccess) {NSLog(rename success);}else{NSLog(rename fail);} } 以上文件操作代码都在iOSStrongDemo可以直接通过git拉下来进行测试。关于NSFileManager的用法还有很多一起接续探索吧转载于:https://www.cnblogs.com/xvewuzhijing/p/5003862.html
http://www.zqtcl.cn/news/559688/

相关文章:

  • 做的比较好的电商网站西安有那些做网站的公司好
  • 哪个网站可以做英语语法题智慧云建筑信息平台
  • 网站怎么做百度才会收录金乡县网站开发
  • 深圳移动网站建站网站如何做播放线路
  • 深圳网站建设q.479185700惠哪个网站可以免费设计房子
  • 迁西网站开发网站建设技术网站建
  • 网站建设与管理课程报告能够做外贸的网站有哪些
  • 浅析社区网站的建设如何建立企业网站
  • 网站建设尺寸像素是多少广州商城型网站建设
  • 重庆自助建站模板简述网络营销的特点
  • 企业网站托管一个月多少钱网页设计规范2018
  • 网站建设费用摊销会计分录合肥网站建设哪里好
  • 郑州市建设工程造价信息网站关于工程项目建设的网站
  • 网站做淘宝客收入咋样景区门户网站建设方案
  • 遵义做网站推广西安都有哪些公司
  • 万网建网站流程产品展示网站模板php
  • 新津县建设局网站网站做301
  • 网站域名续费如何建设一个简易网站
  • 网站整体迁移该怎么做wordpress 图片调用api接口
  • 网站获得流量最好的方法是什么 ( )汕头建设学校的网站
  • 网上下载的网站后台安全吗仿系统之家网站源码
  • 网站实名审核高等教材电工学久久建筑网
  • 化学试剂购买网站网站节点加速
  • 桂林城乡建设局网站在线咨询免费
  • 长治网站设计制作网站ps怎么做网站导航内嵌式
  • 网站 橙色前台网站开发
  • 滨海网站建设服务商电子商务网站建设与维护pdf
  • 企业网站建设方案效果h5网页制作app
  • 国内搜索引擎网站免费无线
  • 龙岩做网站价格室内建筑设计