From 953f408dc65f8ffe97208dded76d5f506842d903 Mon Sep 17 00:00:00 2001 From: mol-cyberwhip <87921877+mol-cyberwhip@users.noreply.github.com> Date: Sun, 25 Jul 2021 14:11:41 +1000 Subject: [PATCH] Load only latest version instead of all files Not a C# user usually so not sure about initializing to null, instead used empty string. Tested and verified it worked on my machine, compiled using dotnet core and .net version 4.8. Adds System.Linq dependency to get access to the .Where string method used in line 24. --- Program.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Program.cs b/Program.cs index c44f03a..d9555dd 100644 --- a/Program.cs +++ b/Program.cs @@ -1,5 +1,6 @@ -using System.IO; +using System.IO; using System; +using System.Linq; namespace Sideloader_Launcher @@ -9,6 +10,8 @@ class Program static void Main(string[] args) { string[] files = Directory.GetFiles(Environment.CurrentDirectory); + string latestVersionFile = ""; + int currMaxVersion = 0; foreach (string file in files) { string fileName = file; @@ -18,9 +21,18 @@ static void Main(string[] args) } if (fileName.StartsWith("Android") && fileName.EndsWith(".exe") && !fileName.Contains("Launcher")) { - System.Diagnostics.Process.Start(file); + int thisVersion = int.Parse(new String(fileName.Where(Char.IsDigit).ToArray())); + if (thisVersion > currMaxVersion) + { + currMaxVersion = thisVersion; + latestVersionFile = fileName; + } } } + if (!(latestVersionFile == "")) + { + System.Diagnostics.Process.Start(latestVersionFile); + } } } }