iOS 相关路径
// 资源目录
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"];