相关疑难解决方法(0)

使用Xamarin android从Asset加载文件

我想从Asset加载文件,我找到了解决方案,但是使用Java。如何将以下Java代码转换为C#。

public String loadKMLFromAsset() {

    String kmlData = null;
    try {

        InputStream is = getAssets().open("yourKMLFile");

        int size = is.available();

        byte[] buffer = new byte[size];

        is.read(buffer);

        is.close();

        kmlData = new String(buffer, "UTF-8");


    } catch (IOException ex) {
        ex.printStackTrace();
        return null;
    }
    return kmlData;

}
Run Code Online (Sandbox Code Playgroud)

c# assets xamarin.android

2
推荐指数
1
解决办法
8441
查看次数

标签 统计

assets ×1

c# ×1

xamarin.android ×1