【问题标题】:unauthorized access exception - access to the path denied - API29未授权访问异常 - 访问路径被拒绝 - API 29
【发布时间】:2021-01-02 07:32:42
【问题描述】:

通过将其路径结尾从 =***** 更改为 =download,我可以访问位于 OneDrive 上的 .txt 文件。然后我尝试使用以下代码下载此文件:

            string fileName = Android.OS.Environment.DirectoryDownloads + "/textfile.txt";
            WebClient web = new WebClient();
            web.UseDefaultCredentials = true;
            web.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            web.DownloadFile(uslugiPath, fileName);

因此,我得到了这个 Unauthorized.Access 异常(访问下载被拒绝)。

我检查了 [This] (Xamarin : Android : System.UnauthorizedAccessException: Access to the path is denied) 主题和许多其他主题,但没有找到解决方案。

Permissins.CheckStatusAsync 结果给出“Granted”。

API 29

【问题讨论】:

    标签: xamarin onedrive


    【解决方案1】:

    在我的情况下,解决方案是使用定义的路径

    var fileName = global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath

    【讨论】:

    • 你可以标记这个答案,这将帮助更多有同样问题的人:)。
    猜你喜欢
    • 1970-01-01
    • 2016-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多