When using Server.MapPath in ASP.NET, the developers can specify the characters as shown below.
var path1 = Server.MapPath(“.”)
var path2 = Server.MapPath(“..”)
var path3 = Server.MapPath(“~”)
var path4 = Server.MapPath(“/”)
What is the difference between the above methods ?
Assume that the website is installed in the path D:\WebApplications\Abundantcode and the root of the IIS is C:\Inetpub\wwwroot and assume that the current page is http://abundantcode.com/popularposts
The path1 will contain D:\WebApplications\Abundantcode\popularposts which is the current physical directory of the file
Path 2 will contain D:\WebApplications\Abundantcode\ which is the parent directory
Path 3 will contain D:\WebApplications\Abundantcode\ which is the physical path of the root of the application.
Path 4 will contain C:\Inetpub\wwwroot which is root of the domain name.