//应用程序目录
1 /Documents 2. /Library/Caches 3. /Library/Preferences 4. /tmp
文件操作:
创建文件:
[[NSFileManager defaultManager] createFileAtPath:filePath];
创建文件夹:
[[NSFileManager defaultManager] createDirectoryAtPath:folerPath ......];
判断文件是否存在:
[[NSFileManager defaultManager] fileExistsAtPath:filePath];
删除文件(文件夹):
[[NSFileManager defaultManager] removeItemAtPath:filePath];
路径获取:
资源包路径:
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
Documents文件路径:
1.
NSString* filePath = NSHomeDirectory();
NSString *documentsPath = [filePath stringByAppendingPathComponent:@"Documents"];
2.
NSArray *pathsArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *
documentsPath = [pathsArray objectAtIndex:0];
绝对路径、相对路径:
NSString *path = @"~/aaa.txt";
NSString *absolutePath = [Path stringByExpendingTildeInPath];
NSString *relativePath = [absolutePath stringByAbbreviatingWithTildeInPath];