How Can I Find The Path To A Folder from a Controller Constructor in ASP.NET MVC?

后端 未结 3 886
野的像风
野的像风 2021-02-13 15:30

I am trying to get the path to a folder in my website root and save it to a class property when my controller constructor is called:

public TestController:Contro         


        
3条回答
  •  我在风中等你
    2021-02-13 15:41

    AppDomain.CurrentDomain.BaseDirectory will give you the root of your site. So:

    temp = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TheFolder");
    

    (Update thanks to Marc Gravell's comment)

提交回复
热议问题