当我想要删除文件夹及其容器时,我发现了一个问题。
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let downloadDirectory:URL = urls.appendingPathComponent("Download")
let manager = FileManager.default
let pathString = downloadDirectory.absoluteString // file:///Users/...
let path = downloadDirectory.path // /Users/...
然后
let directoryContents:[Any]? = try? manager.contentsOfDirectory(atPath: path)
运作良好,但
let directoryContents:[Any]? = try? manager.contentsOfDirectory(atPath: pathString)
无法找到文件夹