0

I need to convert .net core console app into window service and send an email to the list of user from database at 6 om everyday. I am using appsettings.json file from previous project of .net core but now I dont know how to merge it to app.config file. That's why I repeatedly getting an error : {"The configuration file 'appsettings.json' was not found and is not optional. The physical path is 'C:\\WINDOWS\\system32\\appsettings.json'.":null}

  • Don't post code with private API keys, you probably don't want to give the whole world access to that. – Slugsie Jul 23 '21 at 08:30
  • Please change your API key. Even when edited, some (trusted) users can still see the history. – nilsK Jul 23 '21 at 09:03
  • Just a thougt: why a Windows service? You could set up a scheduled Windows task to be exceuted once, instead of a permanantly running service – nilsK Jul 23 '21 at 09:15

1 Answers1

1

I think that you're fighting with the wrong enemy here. From the error text I can understand that Directory.GetCurrentDirectory() returns to you system32 path ("C:\WINDOWS\system32\).

Either this directory should contain your desired apsettings.json or you should change the base path.

There is no need to "merge it with app.config" as far as I understand

Also you should probably delete your ApiKey from this question

HaroldMorgan
  • 164
  • 1
  • 7