I am trying to get the root folder of the application. I have used the following code, but this gives the bin folder, but what I need is the root folder of the application. Is it possible to get this?
// This is the full directory and exe name
String fullAppName = Assembly.GetExecutingAssembly().GetName().CodeBase;
// This strips off the exe name
String fullAppPath = Path.GetDirectoryName(fullAppName);
The location where your exe is, is the root of the application.
You can use
string appPath = Path.GetDirectoryName(Application.ExecutablePath);to get the application path.If you want to find the folder the solution is in, i suggest starting at the exe location, then walking up the directory tree until you get to a folder containing a .sln file. Not too sure why you’d like to do this though.
EDIT: Just figured out you’re creating an asp.net site. In which case you should be able to use below (found here):