In another project, I wanted to point to a file in the App_Data folder of my project. So in Web.Config I added this.
<appSettings>
<add key="filePath" value= "App_Data/MyFile.xml" />
</appSettings>
Then in my controller, I used this to get access to the file.
string relativePath = ConfigurationManager.AppSettings["filePath"];
string xmlData = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, relativePath);
That works great, but now, I need to get to a file in another project, in the same solution.
BaseDirectory points to the project folder I'm currently in. What can I do to get one level up from there? Is there a way I can just get the path of the solution?
Further Information
To be more clear, I want to open a console app from my web app. Right now I'm doing that calling a controller that gets the hardcoded path to the exe like this. I need this path to be relative instead.
Process process = new Process();
//Path of the file
process.StartInfo.FileName = "C:\\Users\\MyName\\Documents\\Visual Studio 2015\\Projects\\SolutionName\\ConsoleApp\\bin\\Debug\\ConsoleApp.exe";
process.Start();
UPDATE
Rather than go into another project, I just changed the output path of the console application to the bin/Debug folder of the WebApp project. That way I can stay in the same project folders and reach the console app with the same relative path stuff I used before.