這篇文章主要介紹了asp.net獲取網站目錄物理路徑的方法,需要的朋友可以參考下
頁面後台cs文件的相對網站根目錄的路徑/view/Atlas 代碼如下: string rootPath1= Server.MapPath("~"); string rootPath2 = Request.ApplicationPath; string path1 = Server.MapPath("upload"); string path2 = Server.MapPath(""); string path3 = Server.MapPath("."); string path4 = Server.MapPath(".."); string path5 = Server.MapPath(Request.ServerVariables["PATH_INFO"]); 結果 代碼如下: string rootpath1= "F:ASP.NET_Projects超凡裝飾cfzsWebcfzsWeb"; string rootpath2= "/Web"; string path1 = "F:ASP.NET_Projects超凡裝飾cfzsWebviewAtlasuploadcfzsWebviewAtlasupload"; string path2 = "F:ASP.NET_Projects超凡裝飾cfzsWebviewAtlascfzsWebviewAtlas"; string path3 = "F:ASP.NET_Projects超凡裝飾cfzsWebviewAtlascfzsWebviewAtlas"; string path4 = "F:ASP.NET_Projects超凡裝飾cfzsWebviewcfzsWebview"; string path5 = "F:ASP.NET_Projects超凡裝飾cfzsWebviewAtlasAdd.aspxcfzsWebviewAtlasAdd.aspx";