private void GetVersion() { using (MyWebClient myWebClient = new MyWebClient()) { try { myWebClient.DownloadFile("http://andrey.mosalsky.com/version.txt", "version.dt"); var version = File.ReadAllText("version.dt"); if (version != Assembly.GetExecutingAssembly().GetName().Version.ToString()) { Dispatcher.Invoke((Action)(() => { wMain.Title += " !!!!!Вышло обновление!!!!!"; btnAbout.Content = ((string)btnAbout.Content) + "!!!!!Вышло обновление!!!!!"; btnAbout.Background = Brushes.LightCoral; })); } } catch { } } }
private void DownloadFile() { if (appStarTime <= DateTime.Now) { if (App.IsSilentMode && !Config.MonitorStatus) { Environment.Exit(0); } downloadTryCount++; if (downloadTryCount > 20) { MessageBox.Show("20 раз программа пыталась подключится к ТС прокси, не вышло, программа завершила работу"); Environment.Exit(0); } } string remoteUri = ConfigurationManager.AppSettings["SourceUrl"]; if (remoteUri.Contains("{0}")) { remoteUri = string.Format(remoteUri, GetIp()); } using (MyWebClient myWebClient = new MyWebClient()) { try { myWebClient.DownloadFile(remoteUri, Config.SourceFile); tryCount = 0; } catch (Exception e) { RestartProcesses(e); DownloadFile(); } } }