1

As usual, I added a Settings file to my application:
enter image description here

For now the file contains one datetime property which I assign after the application code ran through:
enter image description here

As usual, I assign the property as follows:

static void Main(string[] args)
{
    Properties.Default.LastUpdate = DateTime.Now;
}

Issue
Normally, I would then save the settings to file as follows but for some reason, VS does not like it:
enter image description here enter image description here

full code as requested:

static void Main(string[] args)
{
    Properties.Default.LastUpdate = DateTime.Now;
    Properties.Default.Save();
    Properties.Default.Reload();
}
julian bechtold
  • 1,875
  • 2
  • 19
  • 49

1 Answers1

0

I would suggest to use the new configuration options provided by .net core.

-> Add appsettings.json to your project

appsettings.json

{
"name" : "Gary"
}

Init

IConfiguration config = new ConfigurationBuilder()
      .AddJsonFile("appsettings.json", true, true)
      .Build();

In this discussion you will also find a way how to update the value at runtime:

ASP.NET Core appsettings.json update in code

Cyril Iselin
  • 596
  • 4
  • 20