-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
59 lines (53 loc) · 1.9 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System.Diagnostics;
using System.Formats.Tar;
using System.Net;
namespace Bootstrapper2
{
internal class Program
{
static string app = "app.jar";
static string[] files = new string[] {"http://localhost/" + app};
static string gameDir = "/.Test";
static string gamePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + gameDir;
static string javaExecutable = gamePath + app;
static void Main(string[] args)
{
if (!Directory.Exists(gamePath))
{
Directory.CreateDirectory(gamePath);
{
}
}
Console.WriteLine("Checking...");
foreach (Process process in Process.GetProcessesByName("launcherDl"))
{
process.Kill();
}
Console.WriteLine("Downloading update...");
foreach (string file in files)
{
string name = file.Substring(file.LastIndexOf("/") + 1);
try
{
new WebClient().DownloadFile(new Uri(file), gamePath + name);
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = javaExecutable,
Arguments = $"java -jar {name}",
RedirectStandardOutput = false,
UseShellExecute = true,
CreateNoWindow = true
};
process.StartInfo = startInfo;
Console.WriteLine("Starting Launcher...");
process.Start();
}
catch (IOException ex)
{
}
}
Environment.Exit(0);
}
}
}