新建个config文件
读取的函数
1 public IList AppConfigGet(string keyName) 2 { 3 string strReturn = string.Empty; 4 XmlDocument document = new XmlDocument(); 5 document.Load(Server.MapPath("~/RealManage/RealActComputeDisparch.config")); 6 ArrayList list = new ArrayList(); 7 XmlNodeList nodes = document.GetElementsByTagName("add"); 8 for (int i = 0; i < nodes.Count; i++) 9 { 10 XmlAttribute attribute = nodes[i].Attributes["key"]; 11 if (attribute != null && (attribute.Value == keyName)) 12 { 13 attribute = nodes[i].Attributes["value"]; 14 if (attribute != null) 15 { 16 list.Add(attribute.Value); 17 18 } 19 } 20 } 21 return list; 22 }
在调用这个函数是要注意
IList list = AppConfigGet("useRow"); foreach(string row in list)//此处的string是list里面的值的类型 {。。。}