private void ReadConfig(string path) { XmlDocument xd = new XmlDocument(); string fileName = path; try { verModle = new VersionModel(); xd.Load(fileName); verModle.LastTime = xd.SelectSingleNode("//LastUpdateTime").InnerText; verModle.Version = xd.SelectSingleNode("//Version").InnerText; verModle.PubNumber = xd.SelectSingleNode("//PubNumber").InnerText; XmlNodeList FileList = xd.SelectNodes("//UpdateFileList/File"); foreach (XmlNode xn in FileList) { string ver = xn.Attributes["Ver"].Value; string lasttime = xn.Attributes["LastTime"].Value; string name = xn.Attributes["Name"].Value; string pubnumber = xn.Attributes["PubNumber"].Value; FileDetails file = new FileDetails(); file.lastime = lasttime; file.version = ver; file.pubnumber = pubnumber; verModle.fileDic[name] = file; } } catch (Exception e) { LogClass.WriteLogFile("readconfig error:" + e.Message); } }
private void buttonInitVersion_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("版本初始化将会删掉版本配置文件,确认初始化?", "提示", MessageBoxButtons.OKCancel); if (dr == DialogResult.OK) { if (File.Exists("UpdateVersion.xml")) { File.Delete("UpdateVersion.xml"); } verModle = new VersionModel(); } }
public Form1() { InitializeComponent(); verModle = new VersionModel(); }