<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IBackend" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1005/Services/Backend/Backend.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IBackend" contract="Service.IBackend" name="BasicHttpBinding_IBackend" />
</client>
</system.serviceModel>
这个代码在我的appconfig文件中,我想阅读和编辑(保存)address
字符串。所以我有一个代码来编辑和读取,ConnectionString和AppSettings下的其他键,但我还没有找到一种方法来访问其他部分。有关此事件的任何建议
我在connectionString上使用了这些代码
public static string GetConnectionString(string key)
{
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
return config.ConnectionStrings.ConnectionStrings[key].ConnectionString.ToString();
}
public static void UpdateConnectionString(string key, string value)
{
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
configFile.ConnectionStrings.ConnectionStrings[key].ConnectionString = value;
configFile.Save(ConfigurationSaveMode.Modified);
}