MonoDroid evaluation System.UnauthorizedAccessException in D

本文关键字:in UnauthorizedAccessException System evaluation MonoDroid | 更新日期: 2023-09-27 18:32:57

场景:

启动单体开发

新的安卓应用程序

将按钮单击委托替换为

string fullPath = "/data/misc.mvvmcross.customermanagement/files/_Caches/Pictures.MvvmCross/";
if (System.IO.Directory.Exists(fullPath))
{
    button.Text = "exists";
}
else
{
    button.Text = "not found";
    Directory.CreateDirectory(fullPath);
}

运行并单击按钮。Directory.CreateDirectory 将失败

System.UnauthorizedAccessException

尝试使用不同的 API 级别创建新的模拟器映像,但问题仍然存在

有什么想法吗?

好的,已经创建新的Android模拟器映像并使用它。现在一切正常。

溶液:为您想要的 API 级别创建一个新的 android 模拟器映像(不要忘记 Google API 支持)

MonoDroid evaluation System.UnauthorizedAccessException in D

我想知道这是否是由某种程序集/包命名问题引起的。

我已经测试了这段代码:

        string fullPath = Path.Combine(FilesDir.Path, "_Caches2/Pictures.MvvmCross/2/");
        if (System.IO.Directory.Exists(fullPath))
        {
            button.Text = "exists";
        }
        else
        {
            button.Text = fullPath;
            Directory.CreateDirectory(fullPath);
        }

。它在 2.3.3 模拟器中工作正常。

数据文件夹模式为:/data/ * package name * /files/

一个包无法访问

另一个包的数据是正确的(我认为)。

所以我想知道您的软件包名称是否以某种方式错误 - 检查应用程序的清单选项卡和清单.xml文件?