Recommended: String.indexOf method introduction The IndexOf() method of the string searches whether a string passed as a parameter appears on the string. If a string is found, it returns the starting position of the character (0 means the first character, and 1 means the second character according to the and so on) If no found, return -1
./Current directory/ Website home directory
../Upper Directory
~/Website virtual directory
If the current website directory is E:/wwwroot application virtual directory is E:/wwwroot/company, the page path browsed is E:/wwwroot/company/news/show.asp
Use in show.asp page
Server.MapPath("./") The return path is: E:/wwwroot/company/news
Server.MapPath("/") The return path is: E:/wwwroot
Server.MapPath("../") The return path is: E:/wwwroot/company
Server.MapPath("~/") The return path is: E:/wwwroot/company
server.MapPath(request.ServerVariables("Path_Info"))
Request.ServerVariables("Path_Translated")
The return paths of the above two methods are D:/wwwroot/company/news/show.asp
The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.
grammar
Server.MapPath( Path )
parameter
Path
Specifies the relative or virtual path to which the physical directory is to be mapped. If Path starts with a forward slash (/) or backslash (/), the MapPath method returns the path as the complete virtual path. If Path does not start with a slash, the MapPath method returns a path that is the same as the path already in the .asp file.
Comments
The MapPath method does not support relative path syntax (.) or (..). For example, the following relative path../MyDir/MyFile.txt returns an error.
The MapPath method does not check whether the returned path is correct or exists on the server.
Because the MapPath method maps only paths regardless of whether the specified directory exists, you can first map the path to the physical directory structure with the MapPath method and then pass it to the component that creates the specified directory or file on the server.
Example
For the following example, the file data.txt and the test.asp file containing the following scripts are both located in the directory C:/Inetpub/Wwwroot/Script. The C:/Inetpub/Wwwroot directory is set as the host directory of the server.
The following example uses the server variable PATH_INFO to map the physical path to the current file. script
<%= server.mappath(Request.ServerVariables("PATH_INFO"))%><BR>
Output
c:/inetpub/wwwroot/script/test.asp<BR>
Since the path parameters in the following example do not start with slash characters, they are relatively mapped to the current directory, here is C:/Inetpub/Wwwroot/Script. script
<%= server.mappath("data.txt")%><BR>
<%= server.mappath("script/data.txt")%><BR>
Output
c:/inetpub/wwwroot/script/data.txt<BR>
c:/inetpub/wwwroot/script/script/data.txt<BR>
The next two examples use the slash character to specify that the returned path should be considered as the full virtual path on the server. script
<%= server.mappath("/script/data.txt")%><BR>
<%= server.mappath("/script")%><BR>
Output
c:/inetpub/script/data.txt<BR>
c:/inetpub/script<BR>
The following example shows how to use a forward slash (/) or a backslash (/) to return to the physical path to the host directory. script
<%= server.mappath("/")%><BR>
<%= server.mappath("/")%><BR>
Output
c:/inetpub/wwwroot<BR>
c:/inetpub/wwwroot<BR>
Share: Introduction to the application of using Osql tools to manage SQL Server Desktop Engine (MSDE 2000) The SQL Server desktop engine (also called MSDE 2000) does not have its own user interface because it is mainly designed to run in the background.