do {
let filePath = "/Users/xxxxx/Desktop/Automation/demo1/test1.txt"
let fileManager = FileManager.default
if (fileManager.fileExists(atPath: filePath))
{
try fileManager.copyItem(atPath: filePath, toPath: "/Users/xxxxxx/Desktop/Automation/")
}
else
{
print("File does not exist")
}
}
catch let error as NSError
{
print("Ooops! Something went wrong: \(error)")
}
在上面的代码中,我得到“文件不存在”,但我100%确保该位置存在该文件。
我在做错什么吗?