Sex*_*yMF 5 c# xml iis linq-to-xml virtual-directory
我现在已经有3天这个问题了.
我有一个标记为Content和的xml文件Always Copy.
该文件已复制到:
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");
Run Code Online (Sandbox Code Playgroud)
我得到以下异常:
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\IIS Express\bin\XMLMetadata\Actions.1.xml'.
为什么在IIS文件夹中搜索过?我该如何访问该文件?
我正在使用IIs Express和VWD2010
您需要使用Web应用程序的相对路径
Server.MapPath("/")+"bin\\XMLMetadata\\Actions.1.xml"
Run Code Online (Sandbox Code Playgroud)
像那样.
| 归档时间: |
|
| 查看次数: |
5422 次 |
| 最近记录: |