XML文件未随应用程序C#2010 Express一起部署 [英] xml file does not deploy with app c# 2010 express

查看:84
本文介绍了XML文件未随应用程序C#2010 Express一起部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vs 2010 express中构建了一个应用程序,其中包含用于某些初始化内容的xml文件.但是,当我使用它并尝试运行它时,它会抛出一个关于xml文件的文件未找到异常,并且它正在查找的路径包括一个文件夹 该名称看起来像一个GUID值.如果我包含一个文本文件,没问题,似乎只是xml文件有问题.我已经尝试将其作为资源来添加,以及通过右键单击该项目并添加一个xml文件来简单地添加它.就代码而言, 这是标准的:

i built an application in vs 2010 express that includes an xml file for some initialization stuff. However, when i pulish it and try to run it, it throws a file not found exception with regard to the xml file and the path it's looking in includes a folder that's name looks like a GUID value. if i include a text file, no problem, just seems to have problem with xml files. I've tried including it as a resource as well as simply adding it by right-clicking the project and adding an xml file. As far as the code, it's standard:

XmlDocument xmlDocument;

XmlDocument xmlDocument;

xmlDocument =新的XmlDocument();

xmlDocument = new XmlDocument();

xmlDocument.Load( @""xml \ xmlAppData.xml" );

xmlDocument.Load(@"xml\xmlAppData.xml");

这就是它崩溃的原因

任何帮助将不胜感激.

推荐答案

您好mtranchi:

欢迎您加入 MSDN 论坛!

 

Hi mtranchi:

Welcome you to MSDN forum!

 

很高兴为您解答.

使用相对路径的XmlDocument.Load()方法,您应该创建一个名为"xml"的新文件夹
这不在您的应用程序目录中,然后在此文件夹中创建xml文件.
因此,您应确保您的xml文件存在于名为"xml"的文件夹中.在应用程序目录中!


最好的问候!

I am appreciated to answer you the question.

The method of XmlDocument.Load() using a Relative path, you should create a new folder named "xml"
which is not in your application directiory and then create your xml-file in this folder.
So, you should make sure that your xml-file exists in the folder named "xml" which is in the application directory!


Best regards!


这篇关于XML文件未随应用程序C#2010 Express一起部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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