How to get Directory while running unit test

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

    Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName;
    

    This will give you the directory you need....

    as

    AppDomain.CurrentDomain.SetupInformation.ApplicationBase 
    

    gives nothing but

    Directory.GetCurrentDirectory().
    

    Have alook at this link

    http://msdn.microsoft.com/en-us/library/system.appdomain.currentdomain.aspx

提交回复
热议问题