How to get root folder of ASP.NET application

前端 未结 4 2119
野趣味
野趣味 2021-01-03 09:00

I am trying to get the root folder of the application. I have used the following code, but this gives the bin folder, but what I need is the root folder of the

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 09:39

    Your program has no knowledge or link to its development environment, so there's no other way for it to know the solution directory other than you to tell him.

    Either go to the parent-parente directory, as other have suggested, or pass it as an argument in the executable, or check this SO post (How do you get the solution directory in C#) that have neat ways to do this.

提交回复
热议问题