[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>
个性签名:做要做好,做到不三不四不如不做。