As usual, I added a Settings file to my application:
For now the file contains one datetime property which I assign after the application code ran through:
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:
full code as requested:
static void Main(string[] args)
{
Properties.Default.LastUpdate = DateTime.Now;
Properties.Default.Save();
Properties.Default.Reload();
}
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.