How to save date of last application run-time?
My current approach is开发者_开发技巧 to store date in .settings file and update it at the end of program, but it doesn't work.
code:
Settings.Default.RunTime = DateTime.Today;
Settings.Default.Save();
how to fix it?
In Properties -> Settings, make sure the name of the setting is "RunTime", the type is "System.DateTime", and the scope is "user". After that, you should be able to use the following code:
// Access setting
Properties.Settings.Default.RunTime= DateTime.Today;
// Save all settings
Properties.Settings.Default.Save();
If you would like more information on application settings, check out this MSDN article.
精彩评论