使用WriteXml(Application.StartupPath +"\\ContactsList.xml"); 
List<strng> lst=new List<string>(File.ReadAllLines(""));
foreach(string s in lst)
{}

解决方案 »

  1.   

    OpenFileDialog ofd = new OpenFileDialog();
    if (ofd.ShowDialog() == DialogResult.OK)
    {
       DataSet dsxml = new DataSet();
       dsxml.ReadXml(ofd.FileName);
       ...........
    }
      

  2.   

    dsxml.WriteXml("保存的路径");比如:存到C盘。dsxml.WriteXml(@"C:\ContactsList.xml");
      

  3.   

    自己解决了,我是用openfiledialog选择的txt文件,因为openfiledialog使用了后就把默认路径更改了,所以必须的加上dlgInport.RestoreDirectory = true;设置一下,还原当前目录