C#读取App.Config的问题

App.Config代码如下,我想将gitStorPath的内容读取出来放到List中,请问如何操作?




    C:\1
    C:\2
    C:\3

用 .NET Framework 提供的 ConfigurationManager 类来读取 App.config 文件中的配置信息。
比如可以这样读取 gitStorPath 节点的值:

using System.Configuration;

List<string> gitStorPathList = new List<string>();

// 获取 gitStorList 节点
var gitStorList = ConfigurationManager.GetSection("gitStorList") as XmlNode;

// 遍历 gitStorPath 节点
foreach (XmlNode gitStorPath in gitStorList.ChildNodes)
{
    gitStorPathList.Add(gitStorPath.InnerText);
}