I'd like to add a config.json
file to my project and have a class read from the file.
I added the file in VS and added the Build Action
= Content
and Copy to output directory
= Copy always
properties.
When building, the file is copied to C:\...\mysolution\myproject\bin\Debug
.
But File.ReadAllText(@"config.json")
throws a FileNotFoundException
.
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
doesn't return the folder where the file is copied:
C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Temporary ASP.NET Files\\root\\2158bea8\\d46fc01c\\assembly\\dl3\\eca14761\\49a747bf_be72d001