我有简单的代码:
NSFileManager *fileManager = [NSFileManager defaultManager];
if (!fileManager) NSLog(@"Manager doesn't exist!");
if(![fileManager fileExistsAtPath:destString]) {
if (![fileManager createDirectoryAtPath:destString withIntermediateDirectories:YES attributes:nil error:&error]){
NSLog(@"%@", [error localizedFailureReason]);
}
}
else NSLog(@"Exists!");
变量:
destString = file://localhost/Users/SOMEUSER/Desktop/NEWFOLDER/
当我试图创建一个文件夹时,程序会写“存在”但在桌面上不存在。当我删除 fileExistsAtPath: 时,没有错误,但也没有目录。谢谢 4 回复!