2010-03-12 72 views
3

我有一个C#网站。它引用了几个编译的dll。 我的dll需要访问网站上的文件夹。 如何从dll中找到网站的根路径?如何从dll找到网站的根路径?

我已经试过

System.Environment.CurrentDirectory - > “C:\ Program Files文件\微软的Visual Studio 9.0 \ Common7 \ IDE”

Assembly.GetExecutingAssembly()的位置 - > C: \ WINDOWS \ Microsoft.NET \框架\ V2.0.50727 \临时ASP.NET文件......

我打算用

System.Web.HttpContext.Current.Server.MapPath()

但System.Web.HttpContext.Current为空。

谢谢!

回答

8

您正在寻找HttpRuntime.AppDomainAppPath属性,该属性可以在ASP.Net AppDomain中的任何位置使用。

+1

非常好,正是我需要的。谢谢! – 2010-03-12 04:17:36