Hi, there,
I call a file in my script like:
CSVConnector.Instance.Open(@"..\..\TestData.csv");
string URL = CSVConnector.Instance.Rows[4]["Value1"].ToString();
I got an error said no row 4 exists, basically cannot read the TestData.csv file.
If I change the script to give full TestData.csv path, it is working properly, so this one works:
CSVConnector.Instance.Open(@"C:\Users\user1\Documents\RanorexStudio Projects\AutomationLib\TestData.csv);
string URL = CSVConnector.Instance.Rows[4]["Value1"].ToString();
The TestData.csv file is at the same folder with Csvconnector.cs inside a project solution.
Anyone has idea here?
Thanks,
file relative path problem
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: file relative path problem
Hi Ruser,
check the Environment.CurrentDirectory property before calling CSVConnector.Instance.Open(@"..\..\TestData.csv");. Probably your current dir + relative path is wrong. Attend that the current (working) directory depends on the location of your exe/dll. So if you add a reference to e.g. AutomationLib which call the csvConnector, the current dir is relating to the location of your DLL.
see: http://msdn.microsoft.com/en-us/library ... ctory.aspx
Best regards,
Christian
Ranoex Support Team
check the Environment.CurrentDirectory property before calling CSVConnector.Instance.Open(@"..\..\TestData.csv");. Probably your current dir + relative path is wrong. Attend that the current (working) directory depends on the location of your exe/dll. So if you add a reference to e.g. AutomationLib which call the csvConnector, the current dir is relating to the location of your DLL.
see: http://msdn.microsoft.com/en-us/library ... ctory.aspx
Best regards,
Christian
Ranoex Support Team
Re: file relative path problem
Or use:
or something similar
Code: Select all
FileName = path.combine(path.GetDirectory(assembly.getexecutingassembly.location),"myfile.csv")