相关疑难解决方法(0)

如何在 Android 上读取 MAUI/Xamarin 中的已部署文件

I have a small MAUI app i'm testing with. Im trying to read a file that was part of the deployment. I have the code below, which works great in a Windows deploy of the MAUI app, but crashes in Android. What is the proper cross-platform way to do this?

        // TODO get from service or xml
        var path = AppDomain.CurrentDomain.BaseDirectory;
        //var path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
        var fullpath = Path.Combine(path, "Services\\questions.json");
        var json = File.ReadAllText(fullpath);
Run Code Online (Sandbox Code Playgroud)

android xamarin.forms .net-core maui

6
推荐指数
1
解决办法
9975
查看次数

标签 统计

.net-core ×1

android ×1

maui ×1

xamarin.forms ×1