访问内容文件在C#中的Web应用程序 [英] Accessing content file in c# web application

查看:168
本文介绍了访问内容文件在C#中的Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有3天在我的脑海这个问题。结果
我有标记为内容的XML文件和<$ C 。$ C>总是复制结果
中的文件复制到:结果
C:\Users\avi\Documents \Visual工作室2010\Projects\ExpressBroker\ExpressBroker\bin\XMLMetadata\Actions.1.xml

I am having this issue on my mind for 3 days now.
I have an xml file that is marked as Content and Always Copy.
The file was copied to:
C:\Users\avi\Documents\Visual Studio 2010\Projects\ExpressBroker\ExpressBroker\bin\XMLMetadata\Actions.1.xml

当访问到文件中:

//like that:
XDocument actions = XDocument.Load("bin\\XMLMetadata\\Actions.1.xml");
//or like that:
XDocument actions = XDocument.Load("XMLMetadata\\Actions.1.xml");
//or like that:
XDocument actions = XDocument.Load("Actions.1.xml");



我得到以下异常:
异常详细信息:系统。 IO.DirectoryNotFoundException:找不到路径C:\Program Files\IIS Express\bin\XMLMetadata\Actions.1.xml的一部分。

为什么被搜查在IIS文件夹?如何访问该文件?

Why is it been searched in the IIS folder? how do i access the file?

我使用IIS Express中VWD2010

I am using IIs Express with VWD2010

推荐答案

您需要通过使用

Server.MapPath("/")+"bin\\XMLMetadata\\Actions.1.xml" 

这样的。

这篇关于访问内容文件在C#中的Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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