Create a config File
<? Xml version = "1.0" encoding = "UTF-8"?>
<! --
Note: In addition to manually editing this file, you can also use the Web management tool
Configure application settings.
You can use the "website"> "Asp. Net configuration" option in Visual Studio.
The complete list of settings and comments is displayed in machine. config. comments,
This file is usually located in
\ Windows \ Microsoft. Net \ Framework \ v2.x \ Config
-->
<Configuration>
<Deleetask>
<! -- The row to be sent -->
<Add key = "useRow" value = "7"/>
<! -- The row to be sent -->
<Add key = "useRow" value = "8"/>
<! -- The row to be sent -->
<Add key = "useRow" value = "9"/>
<! -- The row to be sent -->
<Add key = "useRow" value = "10"/>
<! -- The row to be sent -->
<Add key = "useRow" value = "11"/>
</AppSettings>
<ConnectionStrings/>
<System. web>
</System. web>
</Configuration>
Read Functions
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 }
When calling this function, note that
IList list = AppConfigGet ("useRow ");
Foreach (string row in list) // here the string is the type of the value in list
{...}