我为osx应用程序进行了编码,以从路径查看文件,但是我收到了
错误由于您没有权限,无法打开“备份”文件 查看它。
因此,我想设置访问权限代码以查看该文件列表。如果有任何想法或解决方案,请帮助我。下面粘贴的代码可供参考:
let path = "~/Library/Application Support/MobileSync/Backup/"
let backupDirectory = NSString(string: path).expandingTildeInPath
do
{
let subBackupPaths = try FileManager.default.contentsOfDirectory(atPath: backupDirectory)
for path in subBackupPaths
{
//operations
}
} catch let error {
print(error)
}
Error Domain = NSCocoaErrorDomain代码= 257“文件“备份”无法 因为您没有查看权限而被打开。” UserInfo = {NSUserStringVariant =( 文件夹),NSURL = file:/// Users / rohan / Library / Application%20Support / MobileSync / Backup, NSFilePath = /用户/ rohan /库/应用程序支持/ MobileSync /备份, NSUnderlyingError = 0x600000c6dda0 {Error Domain = NSPOSIXErrorDomain 代码= 1“不允许操作”}}