简体   繁体   English

在Properties.Settings.Default中保存设置

[英]Save settings in Properties.Settings.Default

I have a application which has 6 count down timers. 我有一个应用程序,它有6个倒计时器。 I want the application to store the current end time so in case the computer will shut down, the date will be saved and nothing is lost. 我希望应用程序存储当前结束时间,以防万一计算机关闭,日期将被保存并且没有丢失。

My problem is that the application is saving the date, but when starting the application again it reloads the default settings and not the saved settings. 我的问题是该应用程序正在保存日期,但是当再次启动该应用程序时,它将重新加载默认设置而不是已保存的设置。

Here is what I have 这就是我所拥有的

public MainWindow()
    {
        InitializeComponent();

        SetupTimer(timer0, watch0_0Time, watch0_0Border);
        SetupTimer(timer1, watch0_1Time, watch0_1Border);
        SetupTimer(timer2, watch0_2Time, watch0_2Border);
        SetupTimer(timer3, watch1_0Time, watch1_0Border);
        SetupTimer(timer4, watch1_1Time, watch1_1Border);
        SetupTimer(timer5, watch1_2Time, watch1_2Border);

        timer0.countTo = Properties.Settings.Default.Timer0Date;
        timer1.countTo = Properties.Settings.Default.Timer1Date;
        timer2.countTo = Properties.Settings.Default.Timer2Date;
        timer3.countTo = Properties.Settings.Default.Timer3Date;
        timer4.countTo = Properties.Settings.Default.Timer4Date;
        timer5.countTo = Properties.Settings.Default.Timer5Date;
    }

.... ....

I am saving later with this call 我稍后会保存此通话

Properties.Settings.Default.Timer0Date = timer.countTo;

I hope you can help :D 希望您能提供帮助:D

In c#, you have to call Properties.Settings.Default.Save() . 在c#中,您必须调用Properties.Settings.Default.Save() Otherwise than in VB, in c#, the settings will not be saved automatically after a value change. 否则在VB中,在c#中,值更改后不会自动保存设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM