none
How to get the physical directory of a virtual directory RRS feed

  • 問題

  •  How can I get the physical directory of a virtual directory in IIS of my host machine.

    For example, I have a virtual directory: MyWeb, and I invoke this web application by http://localhost/MyWeb.


    How can I get the physical directory of MyWeb?

    2009年1月30日 下午 10:59

所有回覆

  • Try this: 

    string realPath = Server.MapPath("/"); 

    Note: ASP.NET Web related questions should go to ASP.NET 與 AJAX(ASP.NET and AJAX) forum.

    http://huan-lin.blogspot.com/
    2009年1月31日 下午 12:45
  • Add a additional note:

    If you want to map directory with "~/" started characters, you can convert to absolute virtual directory path by using "VirtualPathUtility.ToAbsolute()", and convert virtual path to physical path with HttpContext.Current.Server.MapPath().
    不想被人認為是小白,就不要總是在做一堆會讓人認為是小白的事。
    2009年1月31日 下午 02:12
    版主