不废话了直接就写代码吧,在Web应用程序中可以用下面的方法
在程序里修改配置文件System.Configuration.Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
在程序里修改配置文件
if (null == config.AppSettings.Settings["test"])
config.Save();
在Windows应用程序中可以使用下面的方法
在程序里修改配置文件System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
在程序里修改配置文件
在程序里修改配置文件
if (config.AppSettings.Settings["setServer"== null)
到这里我需要说一些注意事项
1.在Windows应用程序中默认情况下没有添加对System.configuration的引用,所以即使using System.Configuration;也
无法使用ConfigurationManager,所以我们需要添加System.configuration的引用。

相关文章:

  • 2022-12-23
  • 2021-11-16
  • 2021-11-11
  • 2021-11-09
  • 2021-11-06
  • 2021-10-30
  • 2021-07-06
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2021-07-08
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
相关资源
相似解决方案