基于Properties.Default值的启动窗口 - WPF

时间:2017-08-14 11:01:45

标签: c# wpf windows winforms

我必须根据默认值打开不同的窗口。以下是代码:

public void ChooseNextWindowBasedOnDefaultValue()
{
    if (Settings.Default["DsrType"] == null || Settings.Default["DsrType"].ToString() == "" || Settings.Default["TimeSlot"].ToString() == "")
    {
        ShowMainWindow();
    }

    else if (Settings.Default["DsrType"].ToString().ToLower() == "excel")
    {
        ShowLoadExcelWindow();
    }

    else if (Settings.Default["DsrType"].ToString().ToLower() == "texteditor")
    {
        ShowTextEditorWindow();
    }
}

在我的本地机器上一切正常。当我在其他机器上安装EXE并尝试运行时,没有窗口启动。哪里出错了?我想我无法读取其他机器中的默认值

1 个答案:

答案 0 :(得分:0)

将您的设置添加到Properties - > Settings.settings文件,并使用自动生成的属性访问它们:

if (string.IsNullOrEmpty(Properties.Settings.Default.DsrType) || string.IsNullOrEmpty(Properties.Settings.Default.TimeSlot))
{
    ShowMainWindow();
}
相关问题