- private bool CheckUpdateServerState(string host)
- {
- try
- {
- Ping ping = new Ping();
- return (ping.Send(host).Status == IPStatus.Success);
- }
- catch
- {
- return false;
- }
- }
- private void CheckNewVersion()
- {
- if (this.CheckUpdateServerState("www.binfensoft.cn"))
- {
- Version version = Assembly.GetExecutingAssembly().GetName().Version;
- try
- {
- new WebClient();
- XmlDocument document = new XmlDocument();
- document.Load("http://www.binfensoft.cn/js/BatchRenameVersion.xml");
- Version version2 = new Version(document.SelectSingleNode("/ver/newVer").InnerText);
- if ((version2 > version) && (MessageBox.Show(string.Format("当前程序版本:{0}\r\n发现有新版本:{1}\r\n新版特性:\r\n{2}\r\n\r\n是否下载?", version.ToString(), version2.ToString(), document.SelectSingleNode("/ver/updateInfo").InnerText), "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes))
- {
- Process.Start(document.SelectSingleNode("/ver/downloadUrl").InnerText);
- }
- }
- catch (Exception)
- {
- }
- }
- }
- <?xml version="1.0" encoding="utf-8" ?>
- <ver>
- <newVer>3.5</newVer>
- <downloadUrl>http://www.duote.com/soft/67823.html</downloadUrl>
- <updateInfo>1、增加换肤功能;
- 2、修正某些电脑运行出错的BUG;
- 3、优化细节;
- 2015-12-15</updateInfo>
- </ver>