簡體   English   中英

在Properties.Settings.Default中保存設置

[英]Save settings in Properties.Settings.Default

我有一個應用程序,它有6個倒計時器。 我希望應用程序存儲當前結束時間,以防萬一計算機關閉,日期將被保存並且沒有丟失。

我的問題是該應用程序正在保存日期,但是當再次啟動該應用程序時,它將重新加載默認設置而不是已保存的設置。

這就是我所擁有的

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;
    }

....

我稍后會保存此通話

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

希望您能提供幫助:D

在c#中,您必須調用Properties.Settings.Default.Save() 否則在VB中,在c#中,值更改后不會自動保存設置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM