void SetFormLoad(object sender, EventArgs e)
{
string path=Application.StartupPath+@"userconset.xml";
XmlReader xmldoc=XmlReader.Create(path);//这里提示错误!!
xmldoc.ReadStartElement("userconset");
xmldoc.ReadStartElement("com");
textBox2.Text=xmldoc.ReadString();
xmldoc.ReadEndElement();

}

解决方案 »

  1.   

    string path=Application.StartupPath+@"\userconset.xml";
      

  2.   

    string path = Server.MapPath("~/userconset.xml");
    你的路径错了
      

  3.   

    string path=Application.StartupPath.TrimEnd(new char[] { '\\'})+@"\userconset.xml"; 
      

  4.   

    将path,用MathPath映射一下,看看路径是否正确。
      

  5.   

    给这句下断点:
    string path=Application.StartupPath+@"userconset.xml";
      

  6.   

    void SetFormLoad(object sender, EventArgs e)
            {
                string path=Application.StartupPath+@"userconset.xml";
                XmlReader xmldoc=XmlReader.Create(path);//这里提示错误!!
                xmldoc.ReadStartElement("userconset");
                xmldoc.ReadStartElement("com");
                textBox2.Text=xmldoc.ReadString();
                xmldoc.ReadEndElement();
                
            }这里的Application.StartupPath显然是系统的路径, 而IIS的权限是没有写的权限的,因此而导致了异常,要么给那个目录加上IIS的执行账户的读写权限,或者你只能使用 Server.MapPath("/") 这个目录下的任意目录