在 HTML 中,我知道我可以指定相对路径,例如:
<a href="~/temp/Somecontent.xxx" />
我也想为我的服务器端代码设置相对路径。例如:
File.Exists("../myBusinessLibrary/Bin/Debug/myBusinessLibrary.dll");//where this is a library that supports the web project
找不到文件。我看了Environment.CurrentDirectory
并得到:
"C:\\Program Files (x86)\\IIS Express"
我不认为我的程序集被复制到这个位置。有没有办法设置与服务器端代码一起使用的相对路径?
最佳答案
你可以使用下面的代码
HttpContext.Current.Server.MapPath("relativepath goes here")
关于c# - 指定服务器端代码的相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15710984/