예제 #1
0
        internal void run(string[] args)
        {
            if (args.Length == 1)
            {
                Config420 config        = new Config420(this);
                string    link          = config.Config().Api + "/launcher/";
                string    proccessename = args[0];

                /*
                 * Process.Start("taskkill", "/F /IM " + proccessename);
                 * while (Process.GetProcessesByName(proccessename.Replace(".exe", "")).Length > 0)
                 *  Thread.Sleep(1);
                 */
                foreach (Process process in Process.GetProcessesByName(proccessename.Replace(".exe", "")))
                {
                    process.Kill();
                    process.WaitForExit();
                }
                WebRequest  request  = WebRequest.Create(link);
                WebResponse response = request.GetResponse();
                List <Task> Dl       = new List <Task>();
                using (var reader = new StreamReader(response.GetResponseStream()))
                {
                    string result = reader.ReadToEnd();
                    foreach (string str in result.Split("<a href=\""))
                    {
                        if (str.Split("\">")[0].Contains("Client"))
                        {
                            Dl.Add(DlFile(link, str.Split("\">")[0]));
                        }
                    }
                    Task.WhenAll(Dl).Wait();
                    if (proccessename != "Client.exe")
                    {
                        if (File.Exists(Environment.CurrentDirectory + "\\" + proccessename))
                        {
                            File.Delete(Environment.CurrentDirectory + "\\" + proccessename);
                        }
                        if (File.Exists(Environment.CurrentDirectory + "\\Client.exe"))
                        {
                            File.Move(Environment.CurrentDirectory + "\\Client.exe", Environment.CurrentDirectory + "\\" + proccessename);
                        }
                    }
                    Process.Start(Environment.CurrentDirectory + "\\" + proccessename);

                    /*if (matches.Count == 0)
                     * {
                     *  Console.WriteLine("parse failed.");
                     *  return;
                     * }
                     *
                     * foreach (Match match in matches)
                     * {
                     *  if (!match.Success) { continue; }
                     *
                     * }*/
                }
            }
        }
예제 #2
0
 internal void CheckUpdate()
 {
     using (WebClient web = new WebClient())
     {
         int CloudVersion = int.Parse(web.DownloadString(new Uri(Config.Config().Api + "version.txt")));
         if (CloudVersion > Version)
         {
             Process update = new Process();
             update.StartInfo.FileName  = "updater.exe";
             update.StartInfo.Arguments = Process.GetCurrentProcess().ProcessName + ".exe";
             update.Start();
             Application.Exit();
         }
     }
 }