Public Static stringGetXML (stringnodeName) { stringStrreturn =""; Try { stringFileName =Application.startuppath; stringstrfile = FileName +@"\info.xml"; if(File.exists (strfile)) {XmlDocument Xdoc=NewXmlDocument (); Xdoc. Load (strfile); Try { //get nodes by PathXmlNode XmlNode =NULL; XmlNode= Xdoc. selectSingleNode ("powerconfig/"+nodeName); Strreturn=Xmlnode.innertext; } Catch(Exception ee) {MessageBox.Show ("configuration file Exception! "); } } Else{MessageBox.Show ("wrong file! Please check the confirmation! "); } } Catch(Exception ex) {MessageBox.Show ("Get Configuration Exceptions! "+Ex. Message); } returnStrreturn; } Public Static voidSetxml (stringNodeName,stringvalue) { Try { stringFileName =Application.startuppath; stringstrfile = FileName +@"\info.xml"; if(File.exists (strfile)) {XmlDocument Xdoc=NewXmlDocument (); Xdoc. Load (strfile); Try{Xdoc. selectSingleNode ("powerconfig/"+ nodeName). InnerText =value; Xdoc. Save (strfile); } Catch(Exception ee) {MessageBox.Show (EE. Message); } } Else{MessageBox.Show ("wrong file! Please check the confirmation! "); } } Catch(Exception ex) {MessageBox.Show ("Get Configuration Exceptions! "+Ex. Message); } }
XML Save basic information