找不到xml文件 [英] Could not find xml file

查看:117
本文介绍了找不到xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究wcf。在我的测试项目服务中从xml文件读取数据,然后将其发送到客户端。数据是myClass类型的数组。

服务类有一个函数

I''m studing wcf. In my test project Service read data from xml file and then send it to client. Data is array of type "myClass".
Service class has a function

private XDocument GetDB()
        {
           
            string filePath = "SampleDB.xml"           
            return XDocument.Load(filePath);
        }



此功能在我运行服务应用程序时有效。但是,当我从客户端调用服务时,它不起作用。



位于bin-> debug文件夹中的xml文件的副本。但是当我运行programm时,我看到像这样的异常无法找到文件''C:\Program Files(x86)\ Microsoft Visual Studio 10.0 \ Common7 \IDE \SampleDB.xml''。 />


如何解决这个问题?


This function works when I run the service application. But when I call service from client it doesn''t work.

The copy of xml file located in bin->debug folder. but when i run programm, I see exception like this "Could not find file ''C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\SampleDB.xml''."

How can I solve this?

推荐答案

您需要指定路径!通过询问该文件,该网站将无法找到适合您的位置。指定路径,你就可以了。
You need to specify the path! by asking for just the file, the site will not work out where it is for you. Specify the path and you will be ok.


这篇关于找不到xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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