我想创建一个新的目录,将文件放到它。但是,我越来越
Error Domain=NSCocoaErrorDomain Code=257 "The file “Offline” couldn’t be opened because you don’t have permission to view it."
我能够创建新的目录和文件是否存在。
let offlinePath = fileDirectory.appendingPathComponent("Offline")
try? fileManager.createDirectory(at: offlinePath, withIntermediateDirectories: true, attributes: nil)
files.forEach { file in
if let localUrl = file.localUrl {
do {
try fileManager.moveItem(at: localUrl, to: offlinePath)
file.localUrl = offlinePath
} catch {
print(error)
}
}
你不能移动一个文件到一个目录不附加文件名
do {
let fileName = localUrl.lastPathComponent
let offlineURL = offlinePath.appendingPathComponent(fileName)
try fileManager.moveItem(at: localUrl, to: offlineURL)
file.localUrl = offlineURL
} ...