阅读的Andr​​oid /单声道xml文件 [英] Read xml file in Android/Mono

查看:154
本文介绍了阅读的Andr​​oid /单声道xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读一下我计划包括为我的移动应用程序的一部分的XML文件。我创建了一个名为XML的文件夹,并添加了一个名为的test.xml文件。这些文件生成操作设置为内容。当我运行应用程序崩溃在试图找到该文件。这里是code我使用的是:

I'm trying to read an xml file which I plan to include as part of my mobile application. I've created a folder called "XML" and added a file called "test.xml". The files build action is set to content. When I run the app it crashes on trying to find the file. Here is the code I'm using:

_path = "XML/test.xml";
doc = new XmlDocument();
doc.Load(_path);

以下是错误我得到:

Here is the error I get:

System.IO.DirectoryNotFoundException已经抛出。

System.IO.DirectoryNotFoundException has been thrown.

找不到路径的一部分/XML/test.xml

Could not find a part of the path "/XML/test.xml"

我是否需要以某种方式登记目录/文件夹?感谢您的任何意见,我敢肯定,我只是错过了一些东西简单...

Do I need to register the directory/folder somehow? Thanks for any advice, I'm sure I've just missed something simple...

推荐答案

你的意思是你创建项目内部的XML目录?

Do you mean that you'd created XML directory inside of your project?

如果您要包括XML到你的APK - 最好的方法是创建/res​​/xml/file.xml并阅读里面的应用与资源类之一。
请看看这个线程 - 也许你会发现它有用。从Android的 RES / XML Open XML文档
祝你好运

If you want to include XML to your APK - one of the best ways will be to create /res/xml/file.xml and read it inside application with Resources class. Please have a look at this thread - maybe you'll find it helpful. Open XML file from res/xml in Android Good luck

这篇关于阅读的Andr​​oid /单声道xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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