Ani*_*tha 7 .net c# iis directoryinfo iis-express
我有一个.NET应用程序,我正在尝试调试,我的部分应用程序从我的项目加载一个文件.此文件位于
C:\Users\USER_FOLDER\Documents\Visual Studio 2012\Projects\MY_PROJECT\_templates\myFile.html
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我指定了文件的相对路径,并使用DirectoryInfo类来获取文件的完整目录路径:
string myFile = (new DirectoryInfo("_templates/myFile.html")).FullName;
Run Code Online (Sandbox Code Playgroud)
但是,这将返回以下路径(额外的\作为转义字符):
"C:\\Program Files\\IIS Express\\_templates\\myFile.html"
Run Code Online (Sandbox Code Playgroud)
我期待IIS Express中的调试与我列出的第一条路径匹配时返回的路径,而不是第三条路径.为什么是这样?我需要在项目中设置其他东西以使其正确地获得路径吗?我假设如果我将代码部署到IIS7站点,这不会发生,但我还没有达到测试级别.
Server.MapPath("~/_templates/myFile.html")
Run Code Online (Sandbox Code Playgroud)
HttpServerUtility.MapPath("~/_templates/myFile.html")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12493 次 |
| 最近记录: |