Currently in my solution I have 3 projects. I want to keep only one Excel file in one of them, and read from it in the other two projects. However I am unable to get the dynamic path at run time to keep it in one place.. For now I am using reflection to get the path of it from the calling project using GetCallingAssembly.
How can I can keep it under one project and not hard code the path and use it in the other two projects?
string path = System.Reflection.Assembly.GetCallingAssembly().CodeBase;
string actualPath = path.Substring(0, path.LastIndexOf("bin"));
string projectPath = new Uri(actualPath).LocalPath;
string fileToRead = projectPath + @"TestData.xlsx";
Aucun commentaire:
Enregistrer un commentaire