台州海关TD3600上线版本
This commit is contained in:
38
JJMediSys/cs/ConfigFileReader.cs
Normal file
38
JJMediSys/cs/ConfigFileReader.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace JJMediSys.cs
|
||||
{
|
||||
public class ConfigFileReader
|
||||
{
|
||||
static XmlDocument xmlDocument = null;
|
||||
static string filepath = System.AppDomain.CurrentDomain.BaseDirectory + "\\JJMediSys.exe.config";
|
||||
public static string GetValue(string key)
|
||||
{
|
||||
if (xmlDocument == null)
|
||||
xmlDocument = new XmlDocument();
|
||||
xmlDocument.Load(filepath);
|
||||
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable);
|
||||
XmlNode xmlNode = xmlDocument.SelectSingleNode(key, nsmgr);
|
||||
XmlElement Xe = (XmlElement)xmlNode;
|
||||
return Xe.GetAttribute("value");
|
||||
}
|
||||
public static void SetValue(string appKey, string newValue)
|
||||
{
|
||||
if (xmlDocument == null)
|
||||
xmlDocument = new XmlDocument();
|
||||
xmlDocument.Load(filepath);
|
||||
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable);
|
||||
XmlNode xmlNode = xmlDocument.SelectSingleNode(appKey, nsmgr);
|
||||
XmlElement Xe = (XmlElement)xmlNode;
|
||||
Xe.SetAttribute("value", newValue);
|
||||
xmlDocument.Save(filepath);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user