2010-03-12 71 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