Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Uri AppDomain.CurrentDomain.BaseDirectory relative path

Tags:

c#

How do you get the relative path to AppDomain.CurrentDomain.BaseDirectory into a Uri.

I need to step up "cd ......" from the AppDomain.CurrentDomain.BaseDirectory and then down to other folders.

Do you know how?

Thanks in advance

Regards

like image 839
Chris G. Avatar asked Feb 01 '26 19:02

Chris G.


1 Answers

If you just want to step up one ore more folders and then down, you could use something like this.

To get a file two folders up:

AppDomain.CurrentDomain.BaseDirectory+"..\\..\\Program.cs"

To get a file two folders up and one down:

AppDomain.CurrentDomain.BaseDirectory + "..\\..\\Properties\\AssemblyInfo.cs"

If you just want the path you could do something like this:

Path.GetFullPath(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\Properties\\");
like image 145
Markus Avatar answered Feb 03 '26 07:02

Markus