gpt4 book ai didi

c# - 获取 .NET WEB 应用程序文件系统根目录的通用方法

转载 作者:太空狗 更新时间:2023-10-29 21:15:32 24 4
gpt4 key购买 nike

类似于Ubiquitous way to get the root directory an application is running in via C# ,但该问题似乎与 Win Forms 有关。如何为 Web 表单完成同样的操作?

我在用...

HttpContext.Current.Server.MapPath("~")

这对于处理 HTTP 请求非常有效,但如果像 Quartz.NET 这样的调度程序似乎不起作用调用一个工作(我遇到的问题)。 HttpContext.Current 在该场景中为空,因为未发出实际的 HTTP 请求。

最佳答案

您正在寻找 HttpRuntime.AppDomainAppPath属性(property),也许还有 VirtualPathUtility类。

关于c# - 获取 .NET WEB 应用程序文件系统根目录的通用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2517861/

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