gpt4 book ai didi

c# - 如何从 dll 中找到网站的根路径?

转载 作者:行者123 更新时间:2023-11-30 14:04:14 25 4
gpt4 key购买 nike

我有一个 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com