I just installed ASP.NET 5 and created a Console Application in Visual Studio. I\'ve added a file, config.json, to the root folder of the project.
It looks like this: >
I've managed to solve it like this:
public class Program
{
public IConfiguration Configuration { get; set; }
public Dictionary Paths { get; set; }
public Program(IApplicationEnvironment app,
IRuntimeEnvironment runtime,
IRuntimeOptions options)
{
Paths = new Dictionary();
Configuration = new ConfigurationBuilder()
.AddJsonFile(Path.Combine(app.ApplicationBasePath, "config.json"))
.AddEnvironmentVariables()
.Build();
}
public void Main(string[] args)
{
var pathKeys = Configuration.GetConfigurationSections("TargetFolderLocations");
foreach (var pathItem in pathKeys)
{
var tmp = Configuration.Get($"TargetFolderLocations:{pathItem.Key}");
Paths.Add(pathItem.Key, tmp);
}
return;
}