1.配置文件Config
<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><appSettings><add key=\"xxxx\" value =\"12345\"/></appSettings></configuration>
2.获取key值
同一项目,可以直接取值
private static string xxxx = ConfigurationManager.AppSettings[\"xxxx\"].ToString();
不同项目,配置路径访问
ExeConfigurationFileMap exc= new ExeConfigurationFileMap();//设置路径,选一种即可exc.ExeConfigFilename = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + \"Config.config\";exc.ExeConfigFilename = @\"D:\\Config\";Configuration AppConfig = ConfigurationManager.OpenMappedExeConfiguration(exc, ConfigurationUserLevel.None);//取值string xxxx = AppConfig.AppSettings.Settings[\"xxxx\"].Value;