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:
{
"Data": {
"TargetFolderLocations": {
"TestFolder1": "Some path",
"TestFolder2": "Another path"
}
}
}
My Program.cs looks like this
public void Main(string[] args)
{
var configurationBuilder = new ConfigurationBuilder(Environment.CurrentDirectory)
.AddJsonFile("config.json")
.AddEnvironmentVariables();
Configuration = configurationBuilder.Build();
//Doesn't work...null all the time
var test = Configuration.Get("Data:TargetFolderLocations");
Console.ReadLine();
}
How can I access the TargetFolderLocations key with code?
Data.TargetFolderLocations?