How to read file from project folder in asp.net core.
I am importing country data using JSON file but that JSON file, I am reading from the computer c drive temp folder. But now I want that to read the JSON file from the project folder.
private void SeedData(EntityTypeBuilder<Country> builder)
{
using (StreamReader r = new StreamReader(@"C:\temp\CountryImport.json"))
{
string json = r.ReadToEnd();
List<Country> countries = JsonConvert.DeserializeObject<List<Country>>(json);
builder.HasData(countries);
}
}