Getting IIS Application filesystem path

前端 未结 2 638
自闭症患者
自闭症患者 2021-02-07 06:09

I have IIS 7.0 installed on and there is a .net application with a .svc service there.

I would like to point a file in the virtual directory pointed by the application (

相关标签:
2条回答
  • 2021-02-07 07:08

    try this might help to resolve your issue

    string apPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
    

    or

    string apPath = System.Web.Hosting.HostingEnvironment.MapPath("~/folder/file");
    
    0 讨论(0)
  • 2021-02-07 07:12

    If you're using a console application project template or any other template other than Web application then you have to add a reference to System.Web.

    You will then be able to refer to the System.Web.Hosting namespace.

    Hope this helps!

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