ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.ExeConfigFilename = @"C:App.config"; ; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None); string connstr = config.ConnectionStrings.ConnectionStrings["connStr"].ConnectionString; MessageBox.Show(connstr); string key = config.AppSettings.Settings["key"].Value; MessageBox.Show(key);
转自http://www.cnblogs.com/MQNH/articles/2942416.html