哦 我先去看下书啊 看别人是怎么解决的
using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using 读写XML文件 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void TTSkinLoad() { DataSet ds = new DataSet(); ds.ReadXml(Application.StartupPath + @"\TTSkinSET.xml"); textBox1.Text = ds.Tables[0].Rows[0][0].ToString(); } private void TTSkinWrite() { DataSet ds = new DataSet(); ds.ReadXml(Application.StartupPath + @"\TTSkinSET.xml"); ds.Tables[0].Rows[0][0] = textBox1.Text; ds.WriteXml(Application.StartupPath + @"\TTSkinSET.xml"); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog openexe = new OpenFileDialog(); openexe.Filter = ""; if (openexe.ShowDialog() == DialogResult.OK) { textBox1.Text = openexe.FileName; TTSkinWrite(); } } private void Form1_Load(object sender, EventArgs e) { if (File.Exists("TTSkinSET.xml")) { TTSkinLoad(); //调用 } else { MessageBox.Show("设置文件不存在"); } } } }