示例#1
0
        /// <summary>
        /// 返回下载更新文件的临时目录
        /// </summary>
        /// <returns></returns>
        public void DownAutoUpdateFile(string downpath)
        {
            if (!System.IO.Directory.Exists(downpath))
            {
                System.IO.Directory.CreateDirectory(downpath);
            }
            string serverXmlFile = downpath + @"Version.xml";

            try
            {
                WebRequest  req = WebRequest.Create(this.UpdaterUrl);
                WebResponse res = req.GetResponse();
                if (res.ContentLength > 0)
                {
                    try
                    {
                        WebClient wClient = new WebClient();
                        wClient.DownloadFile(this.UpdaterUrl, serverXmlFile);
                    }
                    catch
                    {
                        FrmUpdate.WriteLog("下载xml文件异常1");
                        return;
                    }
                }
            }
            catch
            {
                FrmUpdate.WriteLog("下载xml文件异常2");
                return;
            }
            //return tempPath;
        }
示例#2
0
文件: Program.cs 项目: lxshwyan/Lucky
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            FrmUpdate frmUpdate = new FrmUpdate();

            Application.Run(frmUpdate);
        }
示例#3
0
        /// <summary>
        /// 判断是否有更新
        /// </summary>
        /// <returns></returns>
        public bool IsUpdate()
        {
            if (frmU == null)
            {
                frmU      = new FrmUpdate();
                frmU.Name = "frmU";
            }

            return(frmU.IsUpdate);
        }
示例#4
0
 private static void Main(string[] args)
 {
     string location = Assembly.GetExecutingAssembly().Location;
     Environment.CurrentDirectory = Path.GetDirectoryName(location);
     if (!location.EndsWith("temp.exe"))
     {
         string destFileName = location.Replace(".exe", "temp.exe");
         foreach (Process process in Process.GetProcesses())
         {
             if (destFileName.EndsWith(process.ProcessName.ToLower() + ".exe"))
             {
                 for (int i = 0; i < process.Threads.Count; i++)
                 {
                     process.Threads[i].Dispose();
                 }
                 process.Kill();
             }
         }
         try
         {
             System.IO.File.Copy(location, destFileName, true);
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message);
             return;
         }
         if (System.IO.File.Exists(destFileName))
         {
             string arguments = "";
             foreach (string str4 in args)
             {
                 object obj2 = arguments;
                 arguments = string.Concat(new object[] { obj2, '"', str4, '"', " " });
             }
             arguments = arguments.Trim();
             Process.Start(destFileName, arguments);
             return;
         }
     }
     Control.CheckForIllegalCrossThreadCalls = false;
     FrmUpdate mainForm = new FrmUpdate();
     if (mainForm.CheckHasNewVersion())
     {
         Application.Run(mainForm);
     }
 }