The main summary Server.MapPath the use of this method and the use of the scene, not when it is suitable for use;
1, realize the function:
Server.MapPath can obtain the physical path of the specified URL relative to the server, and on the IIS service side, it can obtain the physical path of the file according to its file name;
2, there is a command space:
System.Web.HttpContext.Current.Server.MapPath and System.web.MVC.Control.Server.Mapth;
3, the use of:
Since it's System.Web.HttpContent. It is also timely to show that the method can only be used in http.web, not the environment system will throw an error; what does a non-web environment mean? So, for example, when we use threads to handle a business logic, you use that method when you're using it, and that's an error that you're out of the web environment. Therefore, depending on the situation, the physical address of the virtual directory is obtained, and the method is very effective.
4. Matters needing attention:
System. Web.HttpContext.Current.Server.MapPath ("Mypic") is to obtain the current peer directory address;
System. Web.HttpContext.Current.Server.MapPath (".. /mypic ") is to obtain the current parent directory address;
Use the time need to be cautious;
Server.MapPath query path That's a few things.