ASP MapPath Méthode
Procédé MapPath pour spécifier le chemin mappé sur le chemin d'accès physique correspondant sur le serveur.
Note: Cette méthode ne peut pas être utilisé dans Session.OnEnd et Application.OnEnd.
grammaire
Server.MapPath(path)
参数 | 描述 |
---|---|
path | 必需。映射为物理路径的相对路径或绝对路径。如果该参数以 / 或 \ 开头,则返回完整的虚拟路径。如果该参数不以 / 或 \ 开头,则返回相对于正在被处理的 .asp 文件的路径。 |
Exemples
exemple 1
Par exemple, le test.asp de fichier situé dans C: \ Inetpub \ wwwroot \ Script.
Fichier Test.asp (situé dans le répertoire C: \ Inetpub \ wwwroot \ Script) contient le code suivant:
<%
response.write(Server.MapPath("test.html") & "<br>")
response.write(Server.MapPath("script/test.html") & "<br>")
response.write(Server.MapPath("/script/test.html") & "<br>")
response.write(Server.MapPath("script") & "<br>")
response.write(Server.MapPath("/") & "<br>")
response.write(Server.MapPath("") & "<br>")
%>
输出:
c:inetpubwwwrootscripttest.html
c:inetpubwwwrootscriptscripttest.html
c:inetpubwwwrootscripttest.html
c:inetpubwwwrootscript
c:inetpubwwwroot
c:inetpubwwwroot
response.write(Server.MapPath("test.html") & "<br>")
response.write(Server.MapPath("script/test.html") & "<br>")
response.write(Server.MapPath("/script/test.html") & "<br>")
response.write(Server.MapPath("script") & "<br>")
response.write(Server.MapPath("/") & "<br>")
response.write(Server.MapPath("") & "<br>")
%>
输出:
c:inetpubwwwrootscripttest.html
c:inetpubwwwrootscriptscripttest.html
c:inetpubwwwrootscripttest.html
c:inetpubwwwrootscript
c:inetpubwwwroot
c:inetpubwwwroot
exemple 2
Comment utiliser un chemin relatif au retour pour atteindre le chemin d'accès physique relative est affichée dans le navigateur la page:
<%
response.write(Server.MapPath("../"))
%>
或者:
<%
response.write(Server.MapPath(".."))
%>
response.write(Server.MapPath("../"))
%>
或者:
<%
response.write(Server.MapPath(".."))
%>
Object complète de référence du serveur