System.Web.HttpContext.Current.Server.MapPath()
傳入虛擬路徑 (網址URL,正斜線,例如 https://localhost/)
傳回實體路徑 (檔案總管,反斜線,例如 C:\inetpub\wwwroot )
//Current = C:\OBPV2\OBPV2 Portal\QA\Portal_Web_SSO\Tool\
//Target = C:\OBPV2\OBPV2 Portal\QA\Portal_Web_SSO\LogFiles\SAP Result.txt
//根目錄 C:\inetpub\wwwroot\
string sPath_Root = System.Web.HttpContext.Current.Server.MapPath("/");
//應用程式目錄 C:\\OBPV2\OBPV2 Portal\QA\Portal_Web_SSO\
string sPath_App = System.Web.HttpContext.Current.Server.MapPath("~/");
//上一層目錄 C:\OBPV2\OBPV2 Portal\QA\Portal_Web_SSO\
string sPath_ParentFolder = System.Web.HttpContext.Current.Server.MapPath("../");
//當前目錄 C:\OBPV2\OBPV2 Portal\QA\Portal_Web_SSO\Tool\
string sPath_CurrntFolder = System.Web.HttpContext.Current.Server.MapPath("./");
string sPath_SubFolder = @"LogFiles\";
string sFileName = "SAP Result.txt";
string sPath = sPath_App + sPath_SubFolder + sFileName;
留言列表