public void Install(string installPath)
        {
            MainProgram.DoDebug("Installing new version...");
            if (File.Exists(Path.Combine(MainProgram.dataFolderLocation, "updated.txt")))
            {
                File.Delete("updated.txt");
            }

            HttpWebResponse response = null;
            var             request  = (HttpWebRequest)WebRequest.Create(installPath);

            request.Method = "HEAD";
            bool wentThrough = true;

            try {
                response = (HttpWebResponse)request.GetResponse();
            } catch (WebException ex) {
                //A WebException will be thrown if the status of the response is not `200 OK`
                MainProgram.DoDebug("Failed to update, installation URL does not exist (" + installPath + "). Error;");
                MainProgram.DoDebug(ex.Message);
                MessageBox.Show("Couldn't find the new version online. Please try again later.", "Error | " + MainProgram.messageBoxTitle);
                wentThrough = false;
            } finally {
                if (response != null)
                {
                    response.Close();
                }
            }

            if (!wentThrough)
            {
                return;
            }

            string downloadLocation = Path.Combine(Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), "Downloads"), "AssistantComputerControl installer.exe");

            using (var client = new WebClient()) {
                client.DownloadFile(installPath, downloadLocation);
            }
            Process.Start(downloadLocation);
            MainProgram.Exit();
        }
예제 #2
0
        public void Install()
        {
            MainProgram.DoDebug("Installing new version...");
            //Create file for the updater, containing the name (and full path) of the ACC-exe which is being updated
            if (File.Exists(Path.Combine(MainProgram.dataFolderLocation, "updated.txt")))
            {
                File.Delete("updated.txt");
            }
            if (File.Exists(Path.Combine(MainProgram.dataFolderLocation, "acc_location.txt")))
            {
                File.WriteAllText(Path.Combine(MainProgram.dataFolderLocation, "acc_location.txt"), string.Empty);
            }
            using (var tw = new StreamWriter(Path.Combine(MainProgram.dataFolderLocation, "acc_location.txt"), true)) {
                tw.WriteLine(MainProgram.currentLocationFull);
                tw.Close();
            }
            string downloadLocation = Path.Combine(MainProgram.currentLocation, "ACC_installer.exe");

            using (var client = new WebClient()) {
                client.DownloadFile("https://gh.albe.pw/acc/installer/ACC_installer.exe", downloadLocation);
            }
            Process.Start(downloadLocation);
            MainProgram.Exit();
        }
예제 #3
0
 private void TrayExit(object sender, EventArgs e)
 {
     TrayIcon.Visible = false;
     MainProgram.Exit();
 }