.net(C#) 读取配置文件
1.
设置connectionStrings节点
<connectionStrings>
<add name="ApplicationServices" connectionString="Data Source=192.168.0.14;User ID=sa;Password=sa123; Initial Catalog=Test;Pooling=true"/>
</connectionStrings>
再类中调用:
先添加公共语言 using System.Configuration;
读取:public static readonly string ConnectionStringLocalTransaction = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;
2.
设置appsettings节点:
<appSettings>
<add key="Ftp_url" value="Data Source=192.168.0.14;User ID=sa;Password=sa123; Initial Catalog=Test;Pooling=true;Max Pool Size=40000;Min Pool Size=0;"/>
</appSettings>
再类中调用:
先添加公共语言 using System.Configuration;
读取: string path = ConfigurationManager.AppSettings["Ftp_url"];