diff --git a/src/CSAuto/App.xaml.cs b/src/CSAuto/App.xaml.cs index ce32eed..4f4c03d 100644 --- a/src/CSAuto/App.xaml.cs +++ b/src/CSAuto/App.xaml.cs @@ -35,10 +35,17 @@ public partial class App : Application private string languageName = null; protected override void OnStartup(StartupEventArgs e) { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; AppDomain.CurrentDomain.AppendPrivatePath("bin"); - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + string[] files = Directory.GetFiles(Log.WorkPath, "*.dll"); + bool didCleanOld = files.Length > 0; RealStartup(e); + if (didCleanOld) + { + Process.Start(Log.WorkPath + "\\bin\\updater.exe", "--cleanup \"" + Args + " --restart\""); + App.Current.Shutdown(); + } } void RealStartup(StartupEventArgs e) { diff --git a/src/CSAuto/MainApp.xaml.cs b/src/CSAuto/MainApp.xaml.cs index d97abcc..49b1112 100644 --- a/src/CSAuto/MainApp.xaml.cs +++ b/src/CSAuto/MainApp.xaml.cs @@ -43,7 +43,7 @@ public partial class MainApp : Window #region Constants public const string VER = "2.1.2"; public const string FULL_VER = VER + (DEBUG_REVISION == "" ? "" : " REV "+ DEBUG_REVISION); - const string DEBUG_REVISION = "14"; + const string DEBUG_REVISION = ""; const string GAME_PROCCES_NAME = "cs2"; const string GAME_WINDOW_NAME = "Counter-Strike 2"; const string GAME_CLASS_NAME = "SDL_app"; diff --git a/src/Updater/App.xaml.cs b/src/Updater/App.xaml.cs index cc93122..83c82fc 100644 --- a/src/Updater/App.xaml.cs +++ b/src/Updater/App.xaml.cs @@ -2,7 +2,10 @@ using System.Collections.Generic; using System.Configuration; using System.Data; +using System.Diagnostics; +using System.IO; using System.Linq; +using System.Threading; using System.Threading.Tasks; using System.Windows; @@ -15,7 +18,33 @@ public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { - new MainWindow(e.Args).Show(); + if (e.Args[0] == "--cleanup") + { + string[] files = Directory.GetFiles(Log.WorkPath + "\\..", "*.dll"); + bool didCleanOld = files.Length > 0; + foreach (var file in files) + { + while (true) + { + try + { + File.Delete(file); + break; + } + catch { } + } + } + if (didCleanOld) + { + Directory.Delete(Log.WorkPath + "\\..\\ru"); + File.Delete(Log.WorkPath + "\\..\\steamapi.exe"); + File.Delete(Log.WorkPath + "\\..\\updater.exe"); + } + Process.Start(Log.WorkPath + "\\..\\CSAuto.exe", e.Args[1]); + App.Current.Shutdown(); + } + else + new MainWindow(e.Args).Show(); } } } diff --git a/src/Updater/Log.cs b/src/Updater/Log.cs index c5eb080..4b059bf 100644 --- a/src/Updater/Log.cs +++ b/src/Updater/Log.cs @@ -15,6 +15,7 @@ public static class Log static string path = strWorkPath; static string lineTemplate = "[%date%] (%caller%) - %message%"; + public static string WorkPath { get { return strWorkPath; } } public static void VerifyDir() { try