I have a project named SA.SEPA.UI.Selenium.Integration which contains a folder called Json Data Files that I wish to reference from both a unit test in that project, and a unit test in another project.
I'm having trouble getting the relative path.
With the following string I've tried to get to the folder....
private const string importFilePath = "..\\Json Data Files\\";
..however this returns a relative path of..
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Json Data Files.
How do I get the relative path of files in this folder that will work when accessing the folder from both a unit test in the project, and a unit test from another project (after a reference has been added)?
EDIT
Some code that uses the filepath...
public static List<T> GetAllRecords<T>(JsonType file)
{
string filePath = $"{importFilePath}{file.ToJsonFile()}";
List<T> jsonFileCollection;
using (var r = new StreamReader(filePath))
{
string json = r.ReadToEnd();
jsonFileCollection = JsonConvert.DeserializeObject<List<T>>(json);
}
return jsonFileCollection;
}
And the resultant error when debugging...