एएसपी मैपपाथ विधि
❮ पूरा सर्वर वस्तु संदर्भ
MapPath विधि एक भौतिक पथ के लिए एक निर्दिष्ट पथ को मैप करती है।
नोट: इस पद्धति का उपयोग सत्र में नहीं किया जा सकता है। ऑनएंड और एप्लिकेशन। ऑनएंड।
वाक्य - विन्यास
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 |
उदाहरण
उदाहरण 1
नीचे दिए गए उदाहरण के लिए, फ़ाइल "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
उदाहरण 2
ब्राउज़र में देखे जा रहे पृष्ठ के सापेक्ष भौतिक पथ को वापस करने के लिए एक सापेक्ष पथ का उपयोग कैसे करें:
<%
response.write(Server.MapPath("../"))
%>
or
<%
response.write(Server.MapPath("..\"))
%>
❮ पूरा सर्वर वस्तु संदर्भ