Reprinted: http://blog.sina.com.cn/s/blog_8216ada70100t4p1.html
1.Server. mappath ()Introduction
Server. mappath (string path) is used to returnWebThe physical file path corresponding to the specified virtual path on the server. Its ParametersPathIsWebThe Virtual Path of the server. The returned result isPathThe corresponding physical file path. However, sometimes the parameter is not a virtual path, but a custom file name.
Server. mappath ()The full name isSystem. Web. httpcontext. Current. server. mappath (). Sometimes inProgramDuring debugging, the system prompts "the current context does not have a name."Server""Error. Therefore, the function is not supported.Server. mappath (). Although the namespace"Using system. Web;"Does not help, so you need to use its full name, or the current useServer. mappath ()The class of the function inherits fromSystem. Web. UI. Page.
2.Server. mappath ()Application
Server. mappath (""): Returns the path of the physical file on the current page.
Server. mappath ("/"): Returns the physical file path of the application root directory.
Server. mappath ("./"): Returns the path of the physical file on the current page.
Server. mappath ("../"): Returns the path of the physical file at the upper level of the current page.
Server. mappath ("~ /"): Return the virtual directory (PATH) of the application)
Server. mappath ("~ "): Return the virtual directory (PATH) of the application)
3.Note:Server. mappath ()The returned results may be different in different environments. As shown in the preceding sixServer. mappath ()Application.Vs2010During the test, the second and fourth items will prompt the error "ing path failed", but when changing the position of the program, only the second item will prompt an error. Therefore, different software and environments have different support levels.