我想知道如何在指定路径上创建一个目录。 我使用了"system("目录的路径");",这在模拟器上运行良好,但在设备上不起作用。
我想知道如何在指定路径上创建一个目录。 我使用了"system("目录的路径");",这在模拟器上运行良好,但在设备上不起作用。
// Generate the path to the new directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *newDirectory = [NSString stringWithFormat:@"%@/new", [paths objectAtIndex:0]];
// Check if the directory already exists
if (![[NSFileManager defaultManager] fileExistsAtPath:newDirectory]) {
// Directory does not exist so create it
[[NSFileManager defaultManager] createDirectoryAtPath:newDirectory withIntermediateDirectories:YES attributes:nil error:nil];
}
createDirectoryAtPath:attributes:
方法已经被弃用。
请使用 createDirectoryAtPath:withIntermediateDirectories:attributes:error:
代替。