Working folder in ASP.NET

后端 未结 3 2008
日久生厌
日久生厌 2020-12-20 18:57

We have a web application written in ASP.NET 3.5. In it, we access a file in the code-behind. (Ordinary C# file access, done on the server during the page life-cycle, this

相关标签:
3条回答
  • 2020-12-20 19:44

    In code behind: HttpContext.Current.Server.MapPath("~")

    0 讨论(0)
  • 2020-12-20 19:50

    Use:

    Server.MapPath("~");
    
    0 讨论(0)
  • 2020-12-20 19:55

    To get the path of the root of the application:

    //equivalent to Server.MapPath("/"); if at domain root, e.g Http://mysite.com/
    string path = Server.MapPath("~");
    

    This answer gives a rundown of a few different common Server.MapPath() uses that may also be of use to you.

    0 讨论(0)
提交回复
热议问题