Page 1 of 1

relative path

Posted: Sun Dec 22, 2019 8:07 pm
by IvanT
Could someone tell me how to use relative path to file in ranorex?

Re: relative path

Posted: Mon Dec 23, 2019 2:43 pm
by foals11
Hi,

Can you explain in detail, what do you want to achieve?

If you want to include files into Ranorex, follow these steps. First of all, you have to include the file into the project folder (in my case an excel file). Afterwards, right-click the file in Ranorex Studio and click "Include in project". When the file is included, open the properties and set "Copy to output directory" to "Always".

See my attached screenshots, to comprehend the steps which have been made.

regards,

Re: relative path

Posted: Mon Dec 23, 2019 9:38 pm
by IvanT
Thanks. it is ussefull to me.
i mean that i have string = path to file witch is in currently project.
for example file in directory C:/Program file/project/filesForTesting/name.txt
i think that instead full path to file i can use short path like /filesForTesting/name.txt

Re: relative path

Posted: Fri Dec 27, 2019 9:08 am
by odklizec
Hi,

You can use this code, to return the actual working directory, from which is started your test:

Code: Select all

string getActualDir = TestSuite.WorkingDirectory.ToString();
Then simply add whatever you want at the end of found path (e.g. like this):

Code: Select all

string getDataDir = getActualDir + "\\Data\\file.txt";
or with variable, containing relative path to file:

Code: Select all

string getDataDir = getActualDir + relPathToFile;

Re: relative path

Posted: Fri Dec 27, 2019 11:02 am
by Worker
thank you, i'll try

Re: relative path

Posted: Mon Feb 20, 2023 3:42 pm
by testerad
1. For csv and xls files relative path is recognized by Ranorex:
pic1.png
pic2.png
2. where for mdb files only physical path is recognized by Ranorex:
pic3.png
Relative path for connection string brings errors:
e.g. if file name = \mdbFiles\SNWX-Produkte.mdb

Is short path (relative path) for Access.mdb file possible at all?
How to achieve that?

thank you