Newer
Older
EMS_REFACTOR / UpDateProgress / UpDateProgress / Program.cs
nn-203 on 26 Jul 2017 1 KB first commit
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Xml;

namespace UpDateProgress
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            System.Diagnostics.Process[] proc = System.Diagnostics.Process.GetProcessesByName("Cyberpipe");
            //关闭原有应用程序的所有进程 
            foreach (System.Diagnostics.Process pro in proc)
            {
                pro.Kill();
            }

            string localConfigPath = Application.StartupPath + "/Config.xml";
            string programUrl = getProgramUrl(localConfigPath, "programurl");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FrmDownloadProgress(programUrl));
        }

        //获取新版本程序的路径
        private static string getProgramUrl(string fileName, string nodeName)
        {
            string url = "";
            try
            {
                XmlTextReader xmlReader = new XmlTextReader(fileName);
                while (xmlReader.Read())
                {
                    if (xmlReader.Name == nodeName)
                    {
                        url = xmlReader.ReadElementContentAsString();
                        break;
                    }
                }
                xmlReader.Close();
            }
            catch (Exception e)
            {
                url = "";
            }
            return url;
        }

    }
}