【发布时间】:2023-03-26 08:12:01
【问题描述】:
如何在 OS X 上使用 Swift 复制和粘贴文件夹的全部内容?如果destinationPath 已经包含该文件夹,则应该替换它。
我试过了
let appSupportSourceURL = NSURL(string: appSupportSourcePath)
let appSupportDestinationURL = NSURL(string: appSupportDestinationPath+"/"+appSupportFileName)
if (fileManager.isReadableFileAtPath(appSupportSourcePath)){
do {
try fileManager.copyItemAtURL(appSupportSourceURL!, toURL: appSupportDestinationURL!)}
catch{
}
}
但我意识到,这仅适用于文件。我正在尝试替换整个文件夹。
【问题讨论】:
标签: swift cocoa swift2 filesystems nsfilemanager