读取app.config配置文件信息

Posted 爱编程1314

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了读取app.config配置文件信息相关的知识,希望对你有一定的参考价值。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <appSettings>
        <add key="dbInfo" value="Student" />
    </appSettings>
</configuration>
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            string str = System.Configuration.ConfigurationSettings.AppSettings["dbInfo"].ToString();
            MessageBox.Show(str);
        }
    }
}

以上是关于读取app.config配置文件信息的主要内容,如果未能解决你的问题,请参考以下文章