WINFORM configuration information reading and writing

xiaoxiao2021-03-06  19

public static string GetValue (string AppKey)  { try { string AppKeyValue = System.Configuration.ConfigurationSettings.AppSettings.Get (AppKey);  return AppKeyValue; }  catch (Exception ex) {                                             /   ;  XmlDocument xDoc = new XmlDocument ();  xDoc.Load (System.Windows.Forms.Application.ExecutablePath ".config");   XmlNode xNode;  XmlElement xElem1;  XmlElement xElem2; XNode = xdoc.selectsinglenode ("// appsettings"); Xelem1 = (XMLELEMENT) xnode.selectsinglenode ("// add [@ key = '" appkey "); );                                                      Xelem2.SetaTribute ("Value", AppValue; XNode.Appendchild (Xelem2);} xDoc.save (System.windows.Forms.Application.executablePath ".config");   } #

转载请注明原文地址:https://www.9cbs.com/read-44274.html

New Post(0)