Chris G.
Chris G.

Reputation: 25994

C# Uri AppDomain.CurrentDomain.BaseDirectory relative path

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

Upvotes: 3

Views: 5571

Answers (2)

Chris G.
Chris G.

Reputation: 25994

I ended up using the following:

System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"......\www\");

Upvotes: 1

Markus
Markus

Reputation: 1634

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\\");

Upvotes: 8

Related Questions