android 上的 UnauthorizedAccessException
UnauthorizedAccessException on android
我在尝试检索某些文件时在 Android 上有一个 UnauthorizedAccessException
。奇怪的是,它在今晚之前工作了几个月。
过去几个小时我唯一做的事情是(即使我看不出它有什么改变):
- 正在上传 apk 以启用 alpha 测试 Google Play 服务
- 添加密钥库并对应用程序签名(试过没有签名,同样的问题)
- 正在删除我的测试设备上我的应用程序的最后一个实例(与签名版本不兼容)
该应用程序是使用 Unity 5.5.0f3 构建的,我使用 Application.persistentDataPath
构建我尝试访问的路径。
这里是异常的调用栈:
UnauthorizedAccessException: Access to the path "/storage/emulated/0/Android/data/com.<mycompany>.<myproductname>/files/Saves" is denied.
at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern, SearchOption searchOption) [0x00000] in <filename unknown>:0
at ProfileManager.ParseDirForProfiles (.DirName _dir, .FileExtension _ext) [0x00000] in <filename unknown>:0
at SaveManager.ParseDirForProfiles () [0x00000] in <filename unknown>:0
at myproductname.OnStart () [0x00000] in <filename unknown>:0
at StateMachine.Start () [0x00000] in <filename unknown>:0
导致问题的代码:
及相关设置:
该目录可能仍属于该应用的先前不兼容版本。删除该目录,让您的应用在您下次 运行 时重新创建它。
如果您的应用正常更新,就不会出现这种问题。
我在尝试检索某些文件时在 Android 上有一个 UnauthorizedAccessException
。奇怪的是,它在今晚之前工作了几个月。
过去几个小时我唯一做的事情是(即使我看不出它有什么改变):
- 正在上传 apk 以启用 alpha 测试 Google Play 服务
- 添加密钥库并对应用程序签名(试过没有签名,同样的问题)
- 正在删除我的测试设备上我的应用程序的最后一个实例(与签名版本不兼容)
该应用程序是使用 Unity 5.5.0f3 构建的,我使用 Application.persistentDataPath
构建我尝试访问的路径。
这里是异常的调用栈:
UnauthorizedAccessException: Access to the path "/storage/emulated/0/Android/data/com.<mycompany>.<myproductname>/files/Saves" is denied.
at System.IO.Directory.GetFileSystemEntries (System.String path, System.String searchPattern, FileAttributes mask, FileAttributes attrs) [0x00000] in <filename unknown>:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern) [0x00000] in <filename unknown>:0
at System.IO.Directory.GetFiles (System.String path, System.String searchPattern, SearchOption searchOption) [0x00000] in <filename unknown>:0
at ProfileManager.ParseDirForProfiles (.DirName _dir, .FileExtension _ext) [0x00000] in <filename unknown>:0
at SaveManager.ParseDirForProfiles () [0x00000] in <filename unknown>:0
at myproductname.OnStart () [0x00000] in <filename unknown>:0
at StateMachine.Start () [0x00000] in <filename unknown>:0
导致问题的代码:
及相关设置:
该目录可能仍属于该应用的先前不兼容版本。删除该目录,让您的应用在您下次 运行 时重新创建它。
如果您的应用正常更新,就不会出现这种问题。