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 |
예
실시예 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("..\"))
%>
❮ 전체 서버 개체 참조