读xml的配置文件


//<key name="FilePath">D:\BWBPM\BW\BW_ATTACHMENT\EDCC</key>
public string  ReadConfig(string _name)
  {

   string _value="";

   XmlDocument XmlConfig = new XmlDocument();
   try
   {
    XmlConfig.Load(@"D:\BWBPM\WSS\UserControls\WebPartConfig.config");
   }
   catch
   {

   }

   XmlNodeList XmlKeyList;
   XmlKeyList = XmlConfig.GetElementsByTagName("key");
   foreach( XmlElement key in XmlKeyList )
   {
    if(key.Attributes["name"].Value.ToString()==_name)
    {
     _value=key.InnerText.ToString();
     return _value;
    }
   }
   return _value;
  }

你可能感兴趣的:(配置文件)