How to get Directory while running unit test

后端 未结 14 869
余生分开走
余生分开走 2021-02-02 05:07

Hi when running my unit test I\'m wanting to get the directory my project is running in to retrieve a file.

Say I have a Test project named MyProject. Test I run:

<
14条回答
  •  长情又很酷
    2021-02-02 05:41

    I normally do it like that, and then I just add "..\..\" to the path to get up to the directory I want.

    So what you could do is this:

    var path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"..\..\";
    

提交回复
热议问题