Asp.net获取当前目录的方法小结

前端技术 2023/09/02 .NET

方法一:

string sPath = System.IO.Path.GetDirectoryName(Page.Request.PhysicalPath)

方法二:

string sPath = System.Web.HttpContext.Current.Request.MapPath(\"/\")                                         

方法三:
string sPath = Page.Server.MapPath(\"/\");

我推荐使用第二种

本文地址:https://www.stayed.cn/item/4718

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。