public static string GetXMLValueToString(string AppKey)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.StartupPath + "//" + Application.ProductName + ".exe.config");
XmlNode xNode;
XmlElement xElem1;
xNode = xDoc.SelectSingleNode("//userSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//setting[@name='" + AppKey + "']").FirstChild;
if (xElem1 != null)
return xElem1.OuterXml.Substring(7).Substring(0, xElem1.OuterXml.Length - 15);
}
catch
{
}
return "";
}
public static int GetXMLValueToInt(string AppKey)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.StartupPath + "//" + Application.ProductName + ".exe.config");
XmlNode xNode;
XmlElement xElem1;
xNode = xDoc.SelectSingleNode("//userSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//setting[@name='" + AppKey + "']").FirstChild;
if (xElem1 != null)
return Convert.ToInt32(xElem1.OuterXml.Substring(7).Substring(0, xElem1.OuterXml.Length - 15));
return int.MinValue;
}
catch
{
return int.MinValue;
}
}
public static DateTime GetXMLValueToDateTime(string AppKey)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.StartupPath + "//" + Application.ProductName + ".exe.config");
XmlNode xNode;
XmlElement xElem1;
xNode = xDoc.SelectSingleNode("//userSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//setting[@name='" + AppKey + "']").FirstChild;
if (xElem1 != null)
return Convert.ToDateTime(xElem1.OuterXml.Substring(7).Substring(0, xElem1.OuterXml.Length - 15));
return DateTime.MinValue;
}
catch
{
return DateTime.MinValue;
}
}
public static bool GetXMLValueToBool(string AppKey)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.StartupPath + "//" + Application.ProductName + ".exe.config");
XmlNode xNode;
XmlElement xElem1;
xNode = xDoc.SelectSingleNode("//userSettings");
xElem1 = (XmlElement)xNode.SelectSingleNode("//setting[@name='" + AppKey + "']").FirstChild;
if (xElem1 != null)
return Convert.ToBoolean(xElem1.OuterXml.Substring(7).Substring(0, xElem1.OuterXml.Length - 15));
}
catch
{
}
return false;
}