使用Xamarin android从Asset加载文件 [英] Load a file from Asset using Xamarin android

查看:201
本文介绍了使用Xamarin android从Asset加载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to load a file from the Asset, I found the solution but with Java. How can I convert following Java code to 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;

}

推荐答案

使用

这篇关于使用Xamarin android从Asset加载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆