private static void UpdateClient(string[] updatefilelines) { //FormExecution.HideLogin(); FormExecution.Client_PopMessageBoxShowDialog("Un mise à jour du jeu est disponible !", "Mise à jour"); List <string> updatesToDo = new List <string>(); int i = 0; while (updatefilelines[i] != CLIENT_VERSION.ToString() && i < updatefilelines.Length - 1) { updatesToDo.Add(GetClientUpdateURL(updatefilelines[i])); i++; } updatesToDo.Reverse(); UpdatesInfos infos = new UpdatesInfos { LastVersion = FormExecution.GetLastVersion(updatefilelines).ToString(), Updates = updatesToDo.ToArray(), ProcessName = Assembly.GetExecutingAssembly().Location }; Process p = new Process(); p.StartInfo.FileName = Path.Combine(FormExecution.path, "BattleCityAlpha-Updater.exe"); p.StartInfo.WorkingDirectory = Path.Combine(FormExecution.path); string jsonStr = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(infos))); p.StartInfo.Arguments = jsonStr; p.StartInfo.Verb = "runas"; p.Start(); }
public static bool CheckClientUpdate() { try { using (WebClient wc = new WebClient()) { string query = "http://battlecityalpha.xyz/BCA/UPDATEV2/Client/updates.txt"; string updateCardsStuff = wc.DownloadString(query); string[] updatefilelines = updateCardsStuff.Split( new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None ); if (FormExecution.GetLastVersion(updatefilelines) != CLIENT_VERSION) { UpdateClient(updatefilelines); return(true); } else { return(false); } } } catch (Exception ex) { logger.Error(ex); throw ex; } }