The project I am working on gets configuration by pointing at a folder, in the past the was done by a relative path (e.g. "../../api/data/"), however this was not suitable in all cirumstances as depending on assembly location the relative path to the above would be different, so another method was devised using
System.Reflection.Assembly.GetExecutingAssembly().Location
Ideally we would combine part of the path received from the above with the destination using path.combine() so if the full destination path was "Folder/Core/api/data" and the result from GetExecutingAssembly() was "Folder/Core/Assembly/Assembly.dll", then the plan was to take everything before "/Assembly/" using something like
assemblyPath.Substring(0, assemblyPath.IndexOf($"/Assembly/"))
then combining the result with "../../api/data/" to get the full path.
However I can see now that this will not work if the assembly path is different and does not contain /Assembly/. So I am now wondering what is the best way to dynamically get the full path. I thought about using a switch statement based on the deployment, however that is not very futureproof.