简体   繁体   中英

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

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

I ended up using the following:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM