-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUninstaller.cs
33 lines (30 loc) · 1017 Bytes
/
Uninstaller.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
using BTD_Backend.Natives;
using BTD_Backend.Persistence;
using System;
using System.Diagnostics;
using System.IO;
namespace BTD_Backend
{
/// <summary>
/// Purpose is for completely uninstalling the program using the library
/// </summary>
public class Uninstaller
{
/// <summary>
/// Uninstall the main/executing program that is using BTD Backend
/// </summary>
/// <param name="deleteUserFiles"></param>
public static void UninstallMainProgram(bool deleteUserFiles = false)
{
if (deleteUserFiles)
{
if (Directory.Exists(UserData.MainSettingsDir))
Directory.Delete(UserData.MainSettingsDir, true);
}
Utility.DeleteDirCMD(Environment.CurrentDirectory);
var filename = new FileInfo(UserData.MainProgramExePath);
if (Utility.IsProgramRunning(filename, out Process proc))
Utility.KillProcess(filename);
}
}
}