我有一个 C# 网站。它引用了几个已编译的 dll。 我的 dll 需要访问网站上的文件夹。 如何从dll中找到网站的根路径?
我试过了
System.Environment.CurrentDirectory -> "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE"
Assembly.GetExecutingAssembly().Location -> C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files......
我打算用
System.Web.HttpContext.Current.Server.MapPath()
但 System.Web.HttpContext.Current 为空。
谢谢!
最佳答案
您正在寻找 HttpRuntime.AppDomainAppPath
属性,可以在 ASP.Net AppDomain 中的任何地方使用。
关于c# - 如何从 dll 中找到网站的根路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2430473/