How do I get the path or main route of the project in c #?

0

How to get the path of a project in c #.

Application.StartupPath does not give me the indicated route

string ruta = Path.Combine(Application.StartupPath, @"json\SemanticaColores.json");

I really need to make references to json files inside the json folder, but with getting that route I could move around any project folder

    
asked by Mauro Rivera 04.12.2017 в 20:55
source

1 answer

1

AppDomain.CurrentDomain.BaseDirectory will give you the path where it is situadal to dll, mostly the bin folder. If you want to navigate backwards in the folder, then in combination with Path.Combine you can achieve it:

var jsonFolder = System.IO.Path.Combile(AppDomain.CurrentDomain.BaseDirectory, @"..\json\SemanticaColores.json");

This will give you for example c: /project/json/SemanticaColores.json .

    
answered by 05.12.2017 в 00:39