无法获得项目中文件夹的正确路径位置

时间:2018-11-13 10:40:20

标签: c# directory

我在项目内部创建了一个文件夹,如下所示:

enter image description here

我在Windows资源管理器中获得的路径是

D:\Projekti\SeleniumTesting\SeleniumTesting\ErrorScreenshots

我需要在代码中获取此路径,但是我不想对其进行硬编码,所以我尝试获取如下相对路径:

string finalpath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"ErrorScreenshots\" + screenshotName);
        string localpath = new Uri(finalpath).LocalPath;

但是,调试时得到的路径如下:

D:\\Projekti\\SeleniumTesting\\SeleniumTesting\\bin\\Debug\\ErrorScreenshots\\Screenshot_13112018

关于如何获得“ D:\ Projekti \ SeleniumTesting \ SeleniumTesting \ ErrorScreenshots ”路径的任何想法?

0 个答案:

没有答案