[C#(WinForm)]判断第一次启动程序

来源:https://bbs.csdn.net/topics/220023353/(10楼)

在判断窗口上添加:

string strIsFirstRun = "false";
bool isFirstRun = false;
strIsFirstRun = ConfigurationManager.AppSettings("IsFirstRun");

if (string.IsNullOrEmpty(strIsFirstRun) || strIsFirstRun.ToLower() != "true")
{
   isFirstRun = false;
}
else
{
   isFirstRun = true;
}
strIsFirstRun = "false";

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Remove("IsFirstRun");
config.AppSettings.Settings.Add("IsFirstRun", strIsFirstRun);
config.Save();

 

在app.config里加上:

<appSettings>
   <add key="IsFirstRun" value="true" />
</appSettings>

 

posted @ 2019-07-01 09:09  炎峰森林影  阅读(1805)  评论(0编辑  收藏  举报