ASP MapPath Yöntemi
❮ Komple Sunucu Nesnesi Referansı
MapPath yöntemi, belirtilen bir yolu fiziksel bir yola eşler.
Not: Bu yöntem Session.OnEnd ve Application.OnEnd'de kullanılamaz.
Sözdizimi
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 |
Örnekler
örnek 1
Aşağıdaki örnek için, "test.asp" dosyası C:\Inetpub\Wwwroot\Script içinde bulunur.
"test.asp" dosyası (C:\Inetpub\Wwwroot\Script konumunda bulunur) aşağıdaki kodu içerir:
<%
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
Örnek 2
Göreli fiziksel yolu tarayıcıda görüntülenen sayfaya döndürmek için göreli yol nasıl kullanılır:
<%
response.write(Server.MapPath("../"))
%>
or
<%
response.write(Server.MapPath("..\"))
%>
❮ Komple Sunucu Nesnesi Referansı