How to get Directory while running unit test

后端 未结 14 875
余生分开走
余生分开走 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:43

    I would do it differently.

    I suggest making that file part of the solution/project. Then right-click -> Properties -> Copy To Output = Copy Always.

    That file will then be copied to whatever your output directory is (e.g. C:\Source\MyProject.Test\bin\Debug).

    Edit: Copy To Output = Copy if Newer is the better option

提交回复
热议问题