app.config 信息如下
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Model.set" type="System.Configuration.ClientSettingsSection,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<Model.set>
<setting name="Connection" serializeAs="String">
<value>Data Source=192.168.0.254;Initial Catalog=DB;User ID=fhz;Password=fhzadmin;</value>
</setting>
<setting name="Path" serializeAs="String">
<value>D:\code\</value>
</setting>
</Model.set>
</userSettings>
</configuration>
怎么读取呢????
ConfigurationManager.AppSettings["Connection"].ToString();
读不到呃
<appSettings>
<add key="Connection" value="Data Source=192.168.0.254;Initial Catalog=DB;User ID=fhz;Password=fhzadmin;" />
</appSettings>我记得是这样写的。。。要不我也不知道怎么读取
应该能读到的一般情况下ConfigurationManager.AppSettingd[""].Tostring();或者ConfigurationManager.ConnecString.Tostring();来读取的
app.config 应该这样写吧
<appSettings>
<add key="Connection" value="Data Source=192.168.0.254;Initial Catalog=DB;User ID=fhz;Password=fhzadmin;" />
</appSettings>
public static string FZJG = System.Web.Profile.ProfileBase.Properties["FZJG"].DefaultValue.ToString();
这样读试试
string connection=ConfigurationManager.AppSetting["Connection"].ToString();