在db.cfg文件里面有下面数据,在C#中用什么类来实现读取那?
host=192.168.1.100
port=3306
user=root
password=8692888谢谢!

解决方案 »

  1.   

    string path="f:/db.cfg";
    using (StreamReader sr = File.OpenText(path)) 
    {
    string s = "";
    while ((s = sr.ReadLine()) != null) 
    {
    MessageBox.Show(s);
    }
    }
      

  2.   

    string path="f:/db.cfg";
    using (StreamReader sr = File.OpenText(path)) 
    {
    string s = "";
    while ((s = sr.ReadLine()) != null) 
    {
    MessageBox.Show("key:"+ s.split('=')[0] + "value:"+ s.split('=')[1]);
    }
    }
      

  3.   

    当前应用程序的路径
    Application.StartupPath
      

  4.   

    怎么知道string对象的最后一个字符是是否是'\'字符呢?