iphone中获取文件路径的4种方法
1,document 中的路径 最麻烦的一种:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:filename;
本人自写自用的宏
2,#define ABS_FILE_PATH(FILE_NAME) [NSString stringWithFormat:@"%@/Documents/%@", NSHomeDirectory(),FILE_NAME]
3,获取程序application package目录下的文件路径:
#define PACKAGE_FILE_PATH(FILE_NAME) [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:FILE_NAME]
4,NSString* filePath = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"fileType(txt...html..)"];