所以这是来自客户端的App.config
,但我需要使用C#代码执行此操作,那么任何人都可以帮助我吗?我已经尝试过一些方法来做到这一点,但我仍然无法找到方法。
<!--<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IInfo" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://appserver.gwp.ge/CustomerService/Info.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IInfo"
contract="BillingService.IInfo" name="BasicHttpBinding_IInfo" />
</client>
</system.serviceModel>
</configuration>-->
答案 0 :(得分:0)
这是我的app.config,我没有使用标签的所有内容,但它可以帮助你:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<!-- Example connection to a SQL Server Database on localhost. -->
<add name="MYCONFIG"
connectionString="Data Source=.;Initial Catalog=DBName;Integrated Security=True">
</add>
</connectionStrings>
<appSettings>
<!-- access these values via the property:
System.Configuration.ConfigurationManager.AppSettings[key]
-->
<add key="user" value="myself" />
<add key="rememberUser" value="false"/>
</appSettings>
</configuration>
如何访问它:
Configuration configFile= ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//get value
String s = configFile.AppSettings.Settings["user"].Value;
//set value
configFile.AppSettings.Settings["rememberUser"].Value = "true";
//save
configFile.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");