/// <summary>
        /// Check if dependencies are all OK
        /// </summary>
        private static void CheckDependencies()
        {
            // Check internet connection
            Console.Write("Verifying internet connection . . . ");
            if (NetworkInterface.GetIsNetworkAvailable())
            {
                Console.Write("OK!");
                Console.WriteLine();
            }
            else
            {
                Console.Write("ERROR!");
                Console.WriteLine();
                Console.WriteLine("You are not connected to the internet, the application cannot function without it!");
                if (showUI)
                {
                    Console.ReadKey();
                }
                Environment.Exit(2);
            }

            var hap = "HtmlAgilityPack.dll";

            if (File.Exists(hap))
            {
                Console.WriteLine();
                Console.Write("Verifying HAP MD5 hash . . . ");

                var hash = HashHandler.CalculateMD5(hap);

                if (hash.md5 != HashHandler.HAP_HASH && hash.error == false)
                {
                    Console.Write("ERROR!");
                    Console.WriteLine();
                    Console.WriteLine("Deleting the invalid HAP file.");

                    try {
                        File.Delete(hap);
                    } catch (Exception ex) {
                        Console.WriteLine(ex.ToString());
                    }

                    // delete HAP file as it couldn't be verified
                }
                else if (hash.error)
                {
                    try {
                        File.Delete(hap);
                    } catch (Exception ex) {
                        Console.WriteLine(ex.ToString());
                    }
                }
                else
                {
                    Console.Write("OK!");
                    Console.WriteLine();
                }

                if (debug)
                {
                    Console.WriteLine($"Generated hash: {hash.md5}");
                    Console.WriteLine($"Known hash:     {HashHandler.HAP_HASH}");
                }
            }

            if (!File.Exists(hap))
            {
                Console.WriteLine();
                Console.Write("Attempting to download HtmlAgilityPack.dll . . . ");

                try {
                    using (var webClient = new WebClient()) {
                        webClient.DownloadFile($"https://github.com/ElPumpo/TinyNvidiaUpdateChecker/releases/download/v{offlineVer}/HtmlAgilityPack.dll", "HtmlAgilityPack.dll");
                    }

                    Console.Write("OK!");
                    Console.WriteLine();
                } catch (Exception ex) {
                    Console.Write("ERROR!");
                    Console.WriteLine();
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine();
                }
            }

            // compare HAP version, too
            var currentHapVersion = AssemblyName.GetAssemblyName(hap).Version.ToString();

            if (new Version(HashHandler.HAP_VERSION).CompareTo(new Version(currentHapVersion)) != 0)
            {
                Console.WriteLine($"ERROR: The current HAP libary v{currentHapVersion} does not match the required v{HashHandler.HAP_VERSION}");
                Console.WriteLine("The application will not continue to prevent further errors");
                if (showUI)
                {
                    Console.ReadKey();
                }
                Environment.Exit(1);
            }

            if (SettingManager.ReadSettingBool("Minimal install"))
            {
                if (LibaryHandler.EvaluateLibary() == null)
                {
                    Console.WriteLine("Doesn't seem like either WinRAR or 7-Zip is installed! We are disabling the minimal install feature for you.");
                    SettingManager.SetSetting("Minimal install", "false");
                }
            }

            Console.WriteLine();
        }
        /// <summary>
        /// Downloads the driver and some other stuff
        /// </summary>
        private static void DownloadDriver()
        {
            DriverDialog.ShowGUI();

            if (DriverDialog.selectedBtn == DriverDialog.SelectedBtn.DLEXTRACT)
            {
                // download and save (and extract)
                Console.WriteLine();
                bool error = false;
                driverFileName = downloadURL.Split('/').Last(); // retrives file name from url

                try {
                    string message = "Where do you want to save the drivers?";

                    if (SettingManager.ReadSettingBool("Minimal install"))
                    {
                        message += " (you should select a empty folder)";
                    }

                    var folderSelectDialog = new FolderSelectDialog();
                    folderSelectDialog.Title = message;

                    if (folderSelectDialog.Show())
                    {
                        savePath = folderSelectDialog.FileName + @"\";
                    }
                    else
                    {
                        Console.WriteLine("User closed dialog!");
                        return;
                    }

                    if (File.Exists(savePath + driverFileName) && !DoesDriverFileSizeMatch(savePath + driverFileName))
                    {
                        LogManager.Log($"Deleting {savePath}{driverFileName} because its length doesn't match!", LogManager.Level.INFO);
                        File.Delete(savePath + driverFileName);
                    }

                    // don't download driver if it already exists
                    Console.Write("Downloading the driver . . . ");
                    if (showUI && !File.Exists(savePath + driverFileName))
                    {
                        using (WebClient webClient = new WebClient()) {
                            var notifier = new AutoResetEvent(false);
                            var progress = new Handlers.ProgressBar();

                            webClient.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) {
                                progress.Report((double)e.ProgressPercentage / 100);
                            };

                            // Only set notifier here!
                            webClient.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e) {
                                if (e.Cancelled || e.Error != null)
                                {
                                    File.Delete(savePath + driverFileName);
                                }
                                else
                                {
                                    notifier.Set();
                                }
                            };

                            webClient.DownloadFileAsync(new Uri(downloadURL), savePath + driverFileName);

                            notifier.WaitOne(); // sync with the above
                            progress.Dispose(); // get rid of the progress bar
                        }
                    }
                    // show the progress bar gui
                    else if (!showUI && !File.Exists(savePath + driverFileName))
                    {
                        using (DownloaderForm dlForm = new DownloaderForm()) {
                            dlForm.Show();
                            dlForm.Focus();
                            dlForm.DownloadFile(new Uri(downloadURL), savePath + driverFileName);
                            dlForm.Close();
                        }
                    }
                    else
                    {
                        LogManager.Log("Driver is already downloaded", LogManager.Level.INFO);
                    }
                } catch (Exception ex) {
                    error = true;
                    Console.Write("ERROR!");
                    Console.WriteLine();
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine();
                }

                if (!error)
                {
                    Console.Write("OK!");
                    Console.WriteLine();
                }

                if (debug)
                {
                    Console.WriteLine($"savePath: {savePath}");
                }

                if (SettingManager.ReadSettingBool("Minimal install"))
                {
                    MakeInstaller(false);
                }
            }
            else if (DriverDialog.selectedBtn == DriverDialog.SelectedBtn.DLINSTALL)
            {
                DownloadDriverQuiet(false);
            }
        }
        private static void Main(string[] args)
        {
            string message = "TinyNvidiaUpdateChecker v" + offlineVer;

            LogManager.Log(message, LogManager.Level.INFO);
            Console.Title = message;

            CheckArgs(args);

            RunIntro(); // will run intro if no args needs to output stuff

            if (showUI)
            {
                AllocConsole();

                if (!debug)
                {
                    GenericHandler.DisableQuickEdit();
                }
            }

            SettingManager.ConfigInit();

            CheckDependencies();

            CheckWinVer();

            GetLanguage();

            if (SettingManager.ReadSettingBool("Check for Updates"))
            {
                SearchForUpdates();
            }

            GpuInfo();

            bool hasSelected = false;
            int  iOffline    = 0;

            try {
                iOffline = Convert.ToInt32(OfflineGPUVersion.Replace(".", string.Empty));
            } catch (Exception ex) {
                OfflineGPUVersion = "Unknown";
                Console.WriteLine("Could not retrive OfflineGPUVersion!");
                Console.WriteLine(ex.ToString());
            }

            int iOnline = Convert.ToInt32(OnlineGPUVersion.Replace(".", string.Empty));

            if (iOnline == iOffline)
            {
                Console.WriteLine("Your GPU drivers are up-to-date!");
            }
            else
            {
                if (iOffline > iOnline)
                {
                    Console.WriteLine("Your current GPU driver is newer than remote!");
                }
                if (iOnline < iOffline)
                {
                    Console.WriteLine("Your GPU drivers are up-to-date!");
                }
                else
                {
                    Console.WriteLine("There are new drivers available to download!");
                    hasSelected = true;

                    if (confirmDL)
                    {
                        DownloadDriverQuiet(true);
                    }
                    else
                    {
                        DownloadDriver();
                    }
                }
            }

            if (!hasSelected && forceDL)
            {
                if (confirmDL)
                {
                    DownloadDriverQuiet(true);
                }
                else
                {
                    DownloadDriver();
                }
            }

            Console.WriteLine();
            Console.WriteLine("Finished! Press any key to exit.");
            if (showUI)
            {
                Console.ReadKey();
            }
            LogManager.Log("BYE!", LogManager.Level.INFO);
            Environment.Exit(0);
        }
        /// <summary>
        /// Downloads and installs the driver without user interaction
        /// </summary>
        private static void DownloadDriverQuiet(bool minimized)
        {
            driverFileName = downloadURL.Split('/').Last(); // retrives file name from url
            savePath       = Path.GetTempPath();

            var FULL_PATH_DIRECTORY = savePath + OnlineGPUVersion + @"\";
            var FULL_PATH_DRIVER    = FULL_PATH_DIRECTORY + driverFileName;

            savePath = FULL_PATH_DIRECTORY;

            Directory.CreateDirectory(FULL_PATH_DIRECTORY);

            if (File.Exists(FULL_PATH_DRIVER) && !DoesDriverFileSizeMatch(FULL_PATH_DRIVER))
            {
                LogManager.Log($"Deleting {FULL_PATH_DRIVER} because its length doesn't match!", LogManager.Level.INFO);
                File.Delete(savePath + driverFileName);
            }

            if (!File.Exists(FULL_PATH_DRIVER))
            {
                Console.Write("Downloading the driver . . . ");

                if (showUI || confirmDL)
                {
                    using (var webClient = new WebClient()) {
                        var notifier = new AutoResetEvent(false);
                        var progress = new Handlers.ProgressBar();
                        var error    = false;

                        webClient.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) {
                            progress.Report((double)e.ProgressPercentage / 100);
                        };

                        webClient.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e) {
                            if (e.Cancelled || e.Error != null)
                            {
                                File.Delete(savePath + driverFileName);
                            }
                            else
                            {
                                notifier.Set();
                            }
                        };

                        try {
                            webClient.DownloadFileAsync(new Uri(downloadURL), FULL_PATH_DRIVER);
                            notifier.WaitOne();
                        } catch (Exception ex) {
                            error = true;
                            Console.Write("ERROR!");
                            Console.WriteLine();
                            Console.WriteLine(ex.ToString());
                            Console.WriteLine();
                        }

                        progress.Dispose(); // dispone the progress bar

                        if (!error)
                        {
                            Console.Write("OK!");
                            Console.WriteLine();
                        }
                    }
                }
                else
                {
                    using (DownloaderForm dlForm = new DownloaderForm()) {
                        dlForm.Show();
                        dlForm.Focus();
                        dlForm.DownloadFile(new Uri(downloadURL), FULL_PATH_DRIVER);
                        dlForm.Close();
                    }
                }
            }

            if (SettingManager.ReadSettingBool("Minimal install"))
            {
                MakeInstaller(minimized);
            }

            try {
                Console.WriteLine();
                Console.Write("Executing driver installer . . . ");

                var minimalInstaller = SettingManager.ReadSettingBool("Minimal install");
                var arguments        = minimized ? "/s /noreboot" : "/nosplash";

                Process.Start(SettingManager.ReadSettingBool("Minimal install") ? FULL_PATH_DIRECTORY + "setup.exe" : FULL_PATH_DRIVER, arguments).WaitForExit();
                Console.Write("OK!");
            } catch {
                Console.WriteLine("An error occurred preventing the driver installer to execute!");
            }

            Console.WriteLine();

            try {
                Directory.Delete(FULL_PATH_DIRECTORY, true);
                Console.WriteLine($"Cleaned up: {FULL_PATH_DIRECTORY}");
            } catch {
                Console.WriteLine($"Could not cleanup: {FULL_PATH_DIRECTORY}");
            }
        }
        /// <summary>
        /// Downloads and installs the driver without user interaction
        /// </summary>
        private static void DownloadDriverQuiet(bool minimized)
        {
            driverFileName = downloadURL.Split('/').Last(); // retrives file name from url
            savePath       = Path.GetTempPath();

            string FULL_PATH_DIRECTORY = savePath + OnlineGPUVersion + @"\";
            string FULL_PATH_DRIVER    = FULL_PATH_DIRECTORY + driverFileName;

            savePath = FULL_PATH_DIRECTORY;

            Directory.CreateDirectory(FULL_PATH_DIRECTORY);

            if (File.Exists(FULL_PATH_DRIVER) && !DoesDriverFileSizeMatch(FULL_PATH_DRIVER))
            {
                LogManager.Log("Deleting " + FULL_PATH_DRIVER + " because its length doesn't match!", LogManager.Level.INFO);
                File.Delete(savePath + driverFileName);
            }

            if (!File.Exists(FULL_PATH_DRIVER))
            {
                Console.Write("Downloading the driver . . . ");

                if (showUI || confirmDL)
                {
                    using (WebClient webClient = new WebClient()) {
                        var  notifier = new AutoResetEvent(false);
                        var  progress = new ProgressBar();
                        bool error    = false;

                        webClient.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) {
                            progress.Report((double)e.ProgressPercentage / 100);

                            if (e.BytesReceived >= e.TotalBytesToReceive)
                            {
                                notifier.Set();
                            }
                        };

                        webClient.DownloadFileCompleted += delegate(object sender, AsyncCompletedEventArgs e) {
                            if (e.Cancelled)
                            {
                                File.Delete(FULL_PATH_DRIVER);
                            }
                        };

                        try {
                            webClient.DownloadFileAsync(new Uri(downloadURL), FULL_PATH_DRIVER);
                            notifier.WaitOne();
                        } catch (Exception ex) {
                            error = true;
                            Console.Write("ERROR!");
                            Console.WriteLine();
                            Console.WriteLine(ex.ToString());
                            Console.WriteLine();
                        }

                        progress.Dispose(); // dispone the progress bar

                        if (!error)
                        {
                            Console.Write("OK!");
                            Console.WriteLine();
                        }
                    }
                }
                else
                {
                    using (DownloaderForm dlForm = new DownloaderForm()) {
                        dlForm.Show();
                        dlForm.Focus();
                        dlForm.DownloadFile(new Uri(downloadURL), FULL_PATH_DRIVER);
                        dlForm.Close();
                    }
                }
            }

            if (SettingManager.ReadSettingBool("Minimal install"))
            {
                MakeInstaller(minimized);
            }

            try {
                Console.WriteLine();
                Console.Write("Running installer . . . ");
                if (SettingManager.ReadSettingBool("Minimal install"))
                {
                    Process.Start(FULL_PATH_DIRECTORY + "setup.exe", "/s").WaitForExit();
                }
                else
                {
                    if (minimized)
                    {
                        Process.Start(FULL_PATH_DRIVER, "/s").WaitForExit();
                    }
                    else
                    {
                        Process.Start(FULL_PATH_DRIVER, "/noeula").WaitForExit();
                    }
                }

                Console.Write("OK!");
            } catch {
                Console.WriteLine("Could not run driver installer!");
            }

            Console.WriteLine();

            try {
                Directory.Delete(FULL_PATH_DIRECTORY, true);
                Console.WriteLine("Cleaned up: " + FULL_PATH_DIRECTORY);
            } catch {
                Console.WriteLine("Could not cleanup: " + FULL_PATH_DIRECTORY);
            }
        }
        /// <summary>
        /// Check if dependencies are all OK
        /// </summary>
        private static void CheckDependencies()
        {
            // Check internet connection
            Console.Write("Searching for a network connection . . . ");
            switch (NetworkInterface.GetIsNetworkAvailable())
            {
            case true:
                Console.Write("OK!");
                Console.WriteLine();
                break;

            default:
                Console.Write("ERROR!");
                Console.WriteLine();
                Console.WriteLine("No network connection was found, the application will now determinate!");
                if (showUI)
                {
                    Console.ReadKey();
                }
                Environment.Exit(2);
                break;
            }

            if (!File.Exists("HtmlAgilityPack.dll"))
            {
                Console.WriteLine();
                Console.Write("Attempting to download HtmlAgilityPack.dll . . . ");

                try {
                    using (WebClient webClient = new WebClient()) {
                        webClient.DownloadFile("https://github.com/ElPumpo/TinyNvidiaUpdateChecker/releases/download/v" + offlineVer + "/HtmlAgilityPack.dll", "HtmlAgilityPack.dll");
                    }
                    Console.Write("OK!");
                    Console.WriteLine();
                } catch (Exception ex) {
                    Console.Write("ERROR!");
                    Console.WriteLine();
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine();
                }
            }

            if (SettingManager.ReadSettingBool("Minimal install"))
            {
                if (LibaryHandler.EvaluateLibary() == null)
                {
                    Console.WriteLine("Doesn't seem like either WinRAR or 7-Zip is installed!");
                    DialogResult dialogUpdates = MessageBox.Show("Do you want to disable the minimal install feature and use the traditional way?", "TinyNvidiaUpdateChecker", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dialogUpdates == DialogResult.Yes)
                    {
                        SettingManager.SetSetting("Minimal install", "false");
                    }
                    else
                    {
                        Console.WriteLine("The application will determinate itself");
                        if (showUI)
                        {
                            Console.ReadKey();
                        }
                        Environment.Exit(1);
                    }
                }
            }

            Console.WriteLine();
        }
        /// <summary>
        /// Check if dependencies are all OK
        /// </summary>
        private static void CheckDependencies()
        {
            // Check internet connection
            Console.Write("Verifying internet connection . . . ");
            switch (NetworkInterface.GetIsNetworkAvailable())
            {
            case true:
                Console.Write("OK!");
                Console.WriteLine();
                break;

            default:
                Console.Write("ERROR!");
                Console.WriteLine();
                Console.WriteLine("No internet connection was found, the application will now terminate!");
                if (showUI)
                {
                    Console.ReadKey();
                }
                Environment.Exit(2);
                break;
            }

            var hap = "HtmlAgilityPack.dll";

            if (File.Exists(hap))
            {
                Console.WriteLine();
                Console.Write("Verifying HAP hash . . . ");
                var hash = HashHandler.CalculateMD5(hap);

                if (hash.md5 != HashHandler.HAP_HASH && hash.error == false)
                {
                    Console.Write("ERROR!");
                    Console.WriteLine();
                    Console.WriteLine("Deleting the invalid HAP file.");

                    try {
                        //fFile.Delete(hap);
                    } catch (Exception ex) {
                        Console.WriteLine(ex.ToString());
                    }

                    // delete HAP file as it couldn't be verified
                }
                else if (hash.error)
                {
                    try {
                        File.Delete(hap);
                    } catch (Exception ex) {
                        Console.WriteLine(ex.ToString());
                    }
                }
                else
                {
                    Console.Write("OK!");
                    Console.WriteLine();
                }

                if (debug)
                {
                    Console.WriteLine("Generated hash: " + hash.md5);
                    Console.WriteLine("Known hash:     " + HashHandler.HAP_HASH);
                }
            }

            if (!File.Exists(hap))
            {
                Console.WriteLine();
                Console.Write("Attempting to download HtmlAgilityPack.dll . . . ");

                try {
                    using (WebClient webClient = new WebClient()) {
                        webClient.DownloadFile($"https://github.com/ElPumpo/TinyNvidiaUpdateChecker/releases/download/v{offlineVer}/HtmlAgilityPack.dll", "HtmlAgilityPack.dll");
                    }
                    Console.Write("OK!");
                    Console.WriteLine();
                } catch (Exception ex) {
                    Console.Write("ERROR!");
                    Console.WriteLine();
                    Console.WriteLine(ex.ToString());
                    Console.WriteLine();
                }
            }
            var currentHapVersion = AssemblyName.GetAssemblyName(hap).Version.ToString();

            // compare HAP version too
            if (new Version(HashHandler.HAP_VERSION).CompareTo(new Version(currentHapVersion)) > 0)
            {
                Console.WriteLine("ERROR: The current HAP libary v{0} does not match the wanted v{1}", currentHapVersion, HashHandler.HAP_VERSION);
                Console.WriteLine("The application has been terminated to prevent a error message by .NET");
                if (showUI)
                {
                    Console.ReadKey();
                }
                Environment.Exit(1);
            }

            if (SettingManager.ReadSettingBool("Minimal install"))
            {
                if (LibaryHandler.EvaluateLibary() == null)
                {
                    Console.WriteLine("Doesn't seem like either WinRAR or 7-Zip is installed!");
                    DialogResult dialogUpdates = MessageBox.Show("Do you want to disable the minimal install feature and use the traditional way?", "TinyNvidiaUpdateChecker", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dialogUpdates == DialogResult.Yes)
                    {
                        SettingManager.SetSetting("Minimal install", "false");
                    }
                    else
                    {
                        Console.WriteLine("The application will terminate itself");
                        if (showUI)
                        {
                            Console.ReadKey();
                        }
                        Environment.Exit(1);
                    }
                }
            }

            Console.WriteLine();
        }