日期:2014-05-18 浏览次数:20881 次
<?xml version="1.0" encoding="utf-8"?> <configuration> <AppSettings> <add key="password" value="123456" /> </AppSettings> </configuration>
public string GetAppConfig(string strKey) { try { foreach (string key in ConfigurationManager.AppSettings) { if (key == strKey) { return ConfigurationManager.AppSettings[strKey]; } } return null; } catch(System.Exception ex) { Console.WriteLine("{0} GetAppConfig()Exception caught.", ex); return null; } }