Windows应用程序中的XML文件路径错误 [英] XML file path error in windows application

查看:590
本文介绍了Windows应用程序中的XML文件路径错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我创建了一个带有XML作为我的数据库的Windows应用程序,现在它在我的本地机器上创建它的.exe之后工作正常但是当我在其他机器上运行该exe时它给我错误,无法找到路径:我的本地PC路径的XML文件。

我已经完成谷歌搜索但无法找到该exe也适用于另一台机器的正确路径。

对此有任何帮助。

先谢谢。

Hi guys,
I have created a windows application with XML as my DB, now it works fine after creating .exe of it on my local machine but when I run that exe on other machine it gives me error,"Could not find path:My local PC path of XML file".
I have done Googling but could not find the correct path for which that exe will work on another machine as well.
Any help on this.
Thanks in Advance.

推荐答案

读取这样的文件路径



AppDomain.CurrentDomain.BaseDirectory +\\ myxmlfile.xml



并确保当你是在调试模式下并在visual studio上运行,然后xml文件应该在你的调试文件夹和ur .exe文件中可用。





即,exe和文件应该在样本文件夹中可用

如果这在任何子文件夹中可用,那么就这样给出



AppDomain.CurrentDomai n.BaseDirectory +\\subfolder\\myxmlfile.xml;



其他任何事情需要澄清请告诉我。
Read file path like this

AppDomain.CurrentDomain.BaseDirectory + "\\myxmlfile.xml"

and make sure when u are in debug mode and run this on visual studio then the xml file should available on ur debug folder along with ur .exe file.


ie, the exe and the file should be available in the sample folder
if this is available in any of the sub folder then give like this

AppDomain.CurrentDomain.BaseDirectory + "\\subfolder\\myxmlfile.xml";

Any thing else need to clarify pls let me know.


这篇关于Windows应用程序中的XML文件路径错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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