C#索引超出了数组界限
privatevoidReadXml(){stringfilename=".\\config.xml";System.IO.FileStreamfs=newSystem....
private void ReadXml()
{
string filename = ".\\config.xml";
System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open);
System.IO.StreamReader sr = new System.IO.StreamReader(fs);
XmlDocument doc = new XmlDocument();
doc.Load(sr);
sr.Close();
fs.Close();
XmlElement root = doc.DocumentElement;
XmlNodeList nodeList = root.ChildNodes;
foreach (XmlNode node in nodeList)
{
CheckBox cb = this.Controls.Find(node.Name, false)[0] as CheckBox;-----超出界限
cb.Checked = Convert.ToBoolean(node.InnerText);
}
} 展开
{
string filename = ".\\config.xml";
System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open);
System.IO.StreamReader sr = new System.IO.StreamReader(fs);
XmlDocument doc = new XmlDocument();
doc.Load(sr);
sr.Close();
fs.Close();
XmlElement root = doc.DocumentElement;
XmlNodeList nodeList = root.ChildNodes;
foreach (XmlNode node in nodeList)
{
CheckBox cb = this.Controls.Find(node.Name, false)[0] as CheckBox;-----超出界限
cb.Checked = Convert.ToBoolean(node.InnerText);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询