当然是xml好
用XmlTextReader进行操作,很简单的
http://chs.gotdotnet.com/quickstart/util/srcview.aspx?path=%2fquickstart%2fhowto%2fsamples%2fXml%2fReadXmlFile%2fReadXmlFile.src

解决方案 »

  1.   

    程序当中:
    this.button1.Text = ((string)(configurationAppSettings.GetValue("button1.Text", typeof(string))));app.config文件:
    <?xml version="1.0" encoding="gb2312"?>
    <configuration>
      <appSettings>
        <!--   此处显示用户应用程序和配置的属性设置。-->
        <!--   示例:<add key="settingName" value="settingValue"/> -->
        <add key="button1.Text" value="测试" />
      </appSettings>
    </configuration>
      

  2.   

    补充:
    System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
      

  3.   

    config文件的全名是
    程序名.config
    类似于someone.exe.config
      

  4.   

    public class MyXmlConfig
    {
    private XmlDocument doc;
    private string xmlFileName;
    public bool FileIsTrue = false; public MyXmlConfig(string filename)
    {
    xmlFileName = filename;
    doc = new XmlDocument();
    try
    {
    doc.Load(xmlFileName);
                    FileIsTrue = true;
    }
    catch
    {
    doc.LoadXml("<?xml version=\"1.0\" encoding=\"gb2312\"?><Settings></Settings>");
    FileIsTrue = false;
    }
    } public void Save()
    {
    try
    {
    doc.Save(xmlFileName);
    }
    catch
    {
    }
    } public string Read(string key, string value)
    {
    XmlNode node = doc.DocumentElement.SelectSingleNode(key);
    if (node != null)
    return node.InnerText;
    else
    return value;
    } public void Write(string key, string value)
    {
    XmlNode node = doc.DocumentElement.SelectSingleNode(key);
    if (node != null)
    {
    node.InnerText = value;
    }
    else
    {
    node = doc.DocumentElement;
    string[] path = key.Split(new char[] {'/'});
    for (int i = 0; i < path.Length; i++)
    {
    XmlNode node2;
    if ( (node2 = node.SelectSingleNode(path[i])) == null)
    {
    node2 = doc.CreateElement(path[i]);
    node.AppendChild(node2);
    }
    node = node2;
    }      
    node.InnerText = value;
    }
    }

    //增加一个父节点
    public void Write(string key)
    {
    XmlNode node = doc.DocumentElement.SelectSingleNode(key);
    if (node != null)
    {
    }
    else
    {
    node = doc.DocumentElement;
    string[] path = key.Split(new char[] {'/'});
    for (int i = 0; i < path.Length; i++)
    {
    XmlNode node2;
    if ( (node2 = node.SelectSingleNode(path[i])) == null)
    {
    node2 = doc.CreateElement(path[i]);
    node.AppendChild(node2);
    }
    node = node2;
    }   
    }

    }
    public void ChildWrite(string key,string Childkey,string value)
    {
    XmlNode node = doc.DocumentElement.SelectSingleNode(key);
    XmlNode node2=node.SelectSingleNode(Childkey);
    if(node2!=null)
    {
    node2.InnerText=value;
    }
    else
    {
    XmlNode node3=doc.CreateElement(Childkey);

    node.PrependChild(node3);
    node3.InnerText=value;

    }
    }
    //key为父节点的值,chlidkey为子节点的值。
    public string Read(string key,string Childkey,string value)
    {

    XmlNode node = doc.DocumentElement.SelectSingleNode(key);
    if(node!=null)
    {
    XmlNode node2=node.SelectSingleNode(Childkey);
    if(node2!=null)
    {
    return node2.InnerText;
    }
    else
    return value;
    }
    else
    return value;
    }

    public XmlNodeList NodeRead()
    {
    XmlNode node = doc.ChildNodes[1];

    XmlNodeList nodelist = node.ChildNodes;
    return nodelist; }
    }