Ios中获取文件路径的4种方法

作者:简简单单 2013-09-07
 代码如下 复制代码

 

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,

YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:filename];   

#define ABS_FILE_PATH(FILE_NAME) [NSString stringWithFormat:@"%@/Documents/%@",

NSHomeDirectory(),FILE_NAME]

//获取程序application package目录下的文件路径:
#define PACKAGE_FILE_PATH(FILE_NAME) [[[NSBundle mainBundle] resourcePath]

stringByAppendingPathComponent:FILE_NAME]

NSString* filePath = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"fileType

(txt...html..)"];

相关文章

精彩推荐