ASP MapPath နည်းလမ်း
❮ ဆာဗာအရာဝထ္ထုရည်ညွှန်းချက်ကို အပြီးသတ်ပါ။
MapPath နည်းလမ်းသည် ရုပ်ပိုင်းဆိုင်ရာလမ်းကြောင်းတစ်ခုသို့ သတ်မှတ်ထားသောလမ်းကြောင်းကို မြေပုံဆွဲသည်။
မှတ်ချက်- ဤနည်းလမ်းကို Session.OnEnd နှင့် Application.OnEnd တွင် အသုံးမပြုနိုင်ပါ။
အထားအသို
Server.MapPath(path)
Parameter | Description |
---|---|
path | Required. A relative or virtual path to map to a physical path. If this parameter starts with / or \, it returns a path as if this parameter is a full virtual path. If this parameter doesn't start with / or \, it returns a path relative to the directory of the .asp file being processed |
ဥပမာများ
ဥပမာ ၁
အောက်ပါဥပမာအတွက်၊ "test.asp" ဖိုင်သည် C:\Inetpub\Wwwroot\Script တွင် တည်ရှိသည်။
"test.asp" ဖိုင် (C:\Inetpub\Wwwroot\Script တွင် တည်ရှိသည်) တွင် အောက်ပါ ကုဒ်ပါရှိပါသည်။
<%
response.write(Server.MapPath("test.asp") & "<br>")
response.write(Server.MapPath("script/test.asp") & "<br>")
response.write(Server.MapPath("/script/test.asp") & "<br>")
response.write(Server.MapPath("\script") & "<br>")
response.write(Server.MapPath("/") & "<br>")
response.write(Server.MapPath("\") & "<br>")
%>
Output:
c:\inetpub\wwwroot\script\test.asp
c:\inetpub\wwwroot\script\script\test.asp
c:\inetpub\wwwroot\script\test.asp
c:\inetpub\wwwroot\script
c:\inetpub\wwwroot
c:\inetpub\wwwroot
ဥပမာ ၂
နှိုင်းရရုပ်ပိုင်းဆိုင်ရာလမ်းကြောင်းကို ဘရောက်ဆာတွင် ကြည့်ရှုနေသည့် စာမျက်နှာသို့ ပြန်သွားရန် ဆွေမျိုးလမ်းကြောင်းကို အသုံးပြုနည်း-
<%
response.write(Server.MapPath("../"))
%>
or
<%
response.write(Server.MapPath("..\"))
%>
❮ ဆာဗာအရာဝထ္ထုရည်ညွှန်းချက်ကို အပြီးသတ်ပါ။