代码之家  ›  专栏  ›  技术社区  ›  Biff MaGriff

如何从DLL中找到网站的根路径?

  •  3
  • Biff MaGriff  · 技术社区  · 16 年前

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

    我试过了

    system.environment.currentdirectory->“C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE”

    assembly.getExecutingAssembly()。位置->C:\windows\microsoft.net\framework\v2.0.50727\临时ASP.NET文件…

    我打算用

    system.web.httpcontext.current.server.mappath()。

    但是system.web.httpcontext.current为空。

    谢谢!

    1 回复  |  直到 16 年前
        1
  •  8
  •   SLaks    16 年前

    你在找 HttpRuntime.AppDomainAppPath 属性,它可以在ASP.NET AppDomain中的任何位置使用。