Web.Config中的ASP.NET相对路径文件

时间:2015-08-26 20:23:00

标签: c# asp.net visual-studio web-config

我想在Web.Config文件中指定应用程序中文件的路径,然后在控制器中调用该路径。 从我在网上找到的,我大部分都在那里。

的Web.Config

<appSettings>
    <add key="filePath" value= "~/App_Data/Physicians.xml" />
</appSettings>

控制器

//Path of the document       
string xmlData = ConfigurationManager.AppSettings["filePath"].ToString();

但是,这指的是错误的位置。

enter image description here

如何从我的应用程序的根目录开始,将其指向我存储在App_Data文件夹中的文件?

0 个答案:

没有答案
相关问题