且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取 .NET Web 应用程序中的当前目录

更新时间:2023-01-27 15:14:21

当前目录为系统级特性;它返回启动服务器的目录.与网站无关.

The current directory is a system-level feature; it returns the directory that the server was launched from. It has nothing to do with the website.

你想要HttpRuntime.AppDomainAppPath.

如果您在 HTTP 请求中,您还可以调用 Server.MapPath("~/Whatever").

If you're in an HTTP request, you can also call Server.MapPath("~/Whatever").