c# - How do i get a relative path of a file when running my code in debug for coded ui -


i'm trying not hard code path, have not been able figure our way xml file have included in project under folder labeled datasource. here latest code have tried still doesn't work.

        public static string myassemblydirectory     {                 {             string codebase = assembly.getexecutingassembly().codebase;             uribuilder uri = new uribuilder(codebase);             string path = uri.unescapedatastring(uri.path);             return path.getdirectoryname(path);         }     }            string filename = xmlfilename;          string path = path.combine(myassemblydirectory, @"datasource\" + filename);          xmldocument xdoc = new xmldocument();          xdoc.load(path); 

here output path i'm getting putting in test results output folder.

"c:\myautomation\automated_test_projects\automationprojects\miserreleasetestsuites\testresults\marcw_isd2005m 2016-02-05 10_15_17\out\datasource\miser_login_dts.xml"

if possible i'd point "c:\myautomation\automated_test_projects\automationprojects\miserreleasetestsuites\miserreleasetestsuites\datasource\miser_login_dts.xml"

".." can used go relative parent directory. "." refers current directory.

you can combine these form relative path starts higher in directory tree.

in example need go 3 directories higher out folder , miserreleasetestsuites\datasource folder. combining produces

@"..\..\..\miserreleasetestsuites\datasource\"


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -