IOS下写文件的方法
来源:互联网 发布:模拟画像软件 编辑:程序博客网 时间:2024/06/06 03:02
比如说,我用酷狗的播放器下载歌曲和QQmusic的歌曲,不能放在一起
公共目录不允许使用
才用如下方法:
//==============================================================================
// 资源目录NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:filename];
//==============================================================================
// 获取程序Documents目录路径
// 目录列表
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// 根目录
NSString *documentsDirectory = [paths objectAtIndex:0];
//==============================================================================
// 获取程序Library目录路径
// 目录列表
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
// 根目录
NSString *documentsDirectory = [paths objectAtIndex:0];
//==============================================================================
// 获取程序caches目录
NSArray *cache = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachePath = [cache objectAtIndex:0] ;
//==============================================================================
//根据文件名来获取文件路径 doucument
- (NSString *)dataFilePath:(NSString *)sender
{
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [path objectAtIndex:0];
return [documentDirectory stringByAppendingPathComponent:sender];
}
//==============================================================================
// 获取程序app文件所在目录路径
NSString *homePath = NSHomeDirectory();
//==============================================================================
// 获取程序tmp目录路径
NSString *tempPath = NSTemporaryDirectory();
//==============================================================================
// 获取程序应用包路径
NSString * path = [[NSBundle mainBundle] resourcePath];
// 或
NSString * path = [[NSBundle mainBundle] pathForResource: @"info" ofType: @"txt"];
//==============================================================================
- IOS下写文件的方法
- 将plist文件写到docmentc目录下的方法
- PhoneGap写文件的方法
- CCSV6及CCSV4CCSV5无源文件只有.out文件下的烧写方法
- iOS 9 下写WebView的错误
- iOS实现文件的写操作
- ios ipod library 读,写,等常见管理方法 (下)
- iOS 下的文件操作
- OpenCV下的CSV文件读、写
- Qt下写日志文件的函数
- windows下写日志文件的代码
- linux平台下的写文件刷新
- linux平台下的写文件刷新
- IOS写文件
- ios 追加写文件
- ios 追加写文件
- weblogic下写clob的方法
- eclipse下写普通javabean的方法
- 修改tableview各个 section之间的间隔
- ubuntu 安装jdk,gogent
- ORA-01940: cannot drop a user that is currently connected
- 内存中的数据对齐
- 在前台加入分页的html代码
- IOS下写文件的方法
- 正则表达式学习
- log4j配置
- PowerDesigner 反向工程 Oracle 连接篇
- Oracle PL/SQL判断两个字段相等或不等问题
- 他们为什么成功?中国最赚钱的8家移动游戏公司
- MyEclipse的一些优化方法
- C# Color Name Table http://www.flounder.com/csharp_color_table.htm
- C#餐厅管理系统2--数据连接及登录