我想知道如何在某个目录中创建新文件夹。我该怎么做?我使用NSFileManager
。
答案 0 :(得分:5)
是的,您可以使用NSFileManager的createDirectoryAtPath:withIntermediateDirectories:attributes:error:
方法:
[ [ NSFileManager defaultManager ] createDirectoryAtPath: @"/My/Custom/Path" withIntermediateDirectories: YES attributes: nil error: NULL ];
答案 1 :(得分:0)
Swift 5
let path = "/Users/\(NSUserName())/Downloads/custom"
do {
try FileManager.default.createDirectory(atPath: path, withIntermediateDirectories: true, attributes: nil)
} catch{
print(error)
}