Swift:复制文件错误信息? “......没有访问权限......”

时间:2016-09-02 18:23:06

标签: swift file copy access rights

我只是使用命令将文件从一个路径复制到另一个路径:

let fileManager = NSFileManager.defaultManager()
fileManager.copyItemAtPath(filepath1, toPath: filepath2)

我收到消息:

  

将/ Users / dirk / Documents / Test / Ohne Titel 12.txt复制到   / Users / dirk / Documents / TestCache / Ohne Titel 12.txt:“Ohne Titel 12.txt”   无法复制,因为您无权访问   “TestCache”。

我在通常的用户帐户下运行此代码。我可以使用取景器同时复制文件,但没有任何问题。因此,它不属于“缺失”访问权限的问题。可能是什么原因?什么是解决方案?

添加:

cp '/Users/dirk/Documents/Test/Ohne Titel 12.txt' '/Users/dirk/Documents/TestCache/Ohne Titel 12.txt'

终端工作正常!

0 个答案:

没有答案
相关问题