<SoftWareInfo>
<SoftWareName>...</SoftWareName>
<Version>....</Version>
<Company>.....</Company>
</SoftWareInfo>
#region 读取软件信息Xml文件,软件名
XmlDocument xmlDoc = new XmlDocument();if (File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"SoftWareInfo.xml")))
{
xmlDoc.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"SoftWareInfo.xml"));//加载文件
XmlNode xmlFather1 = xmlDoc.SelectSingleNode("SoftWareInfo");//得到根节点
XmlNodeList xmlFather2 = xmlFather1.ChildNodes; // 得到二级节点列表
bool NameExist = false;
foreach (XmlNode xn1 in xmlFather2)
{
if (xn1.Name == "SoftWareName")
{
if (xn1.InnerText == string.Empty)
{
MessageBox.Show("软件信息文件内容异常!", "文件错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
else
{
NameExist = true;
this.Text = xn1.InnerText;
}
}
if (!NameExist)
{
MessageBox.Show("软件信息文件内容缺失节点!", "文件错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
else
{
MessageBox.Show("软件信息文件丢失!", "缺失文件", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endregion