From b735781beca92ff0c50d6d069ca76e30fb1db47e Mon Sep 17 00:00:00 2001 From: Thomas G <62822072+Thomasluigi07@users.noreply.github.com> Date: Sat, 22 Oct 2022 09:10:55 +1100 Subject: [PATCH] 1.5 --- Form2.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Form2.cs b/Form2.cs index cf4a4a3..89e494d 100644 --- a/Form2.cs +++ b/Form2.cs @@ -8,6 +8,8 @@ using System.Text; using System.Threading; using System.IO; using System.Windows.Forms; +using System.Linq; + namespace ARCHBLOXBootstrapper { public partial class ARCHBLOX : Form @@ -31,6 +33,13 @@ namespace ARCHBLOXBootstrapper shortcut.Save(); } + private static long GetDirectorySize(string folderPath) + { + // get size of a directory, important for showing the user how much space ARCHBLOX takes + DirectoryInfo di = new DirectoryInfo(folderPath); + return di.EnumerateFiles("*", SearchOption.AllDirectories).Sum(fi => fi.Length) / 1000000; + } + public ARCHBLOX() { InitializeComponent(); @@ -50,7 +59,7 @@ namespace ARCHBLOXBootstrapper string version_string = webData; string folderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Archblx\", @"Studio\", @"Versions\"); string clientPath = Path.Combine(folderPath, version_string + @"\"); - string filePath = Path.Combine(clientPath, Path.GetFileName(@"http://archblox.com/client/" + version_string + ".zip")); + string filePath = Path.Combine(clientPath, Path.GetFileName(@"http://archblox.com/studio/" + version_string + ".zip")); string studioPath = Path.Combine(clientPath, "ArchbloxStudio.exe"); ARCHBLOXProtocol.ARCHBLOXURIProtocol.Register(); CreateShortcut(); @@ -72,7 +81,7 @@ namespace ARCHBLOXBootstrapper if (Directory.Exists(folderPath) & DontEvenBother == false) { // ask user if they want to delete previous installs - DialogResult res = MessageBox.Show("Do you want to delete previous installs of ARCHBLOX Studio?", "ARCHBLOX Studio", MessageBoxButtons.YesNo, MessageBoxIcon.Information); + DialogResult res = MessageBox.Show("Do you want to delete previous installs of ARCHBLOX Studio? Current size of ARCHBLOX Studio folder: " + GetDirectorySize(folderPath) + "MB.", "ARCHBLOX Studio", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (res == DialogResult.Yes) { label1.Text = "Removing previous installs..."; @@ -139,7 +148,7 @@ namespace ARCHBLOXBootstrapper double receive = double.Parse(e.BytesReceived.ToString()); double total = double.Parse(e.TotalBytesToReceive.ToString()); double percentage = receive / total * 100; - label2.Text = "Installing ARCHBLOX... (" + Math.Truncate(percentage).ToString() + "% Completed)"; + label2.Text = "Installing ARCHBLOX... (" + Math.Truncate(percentage).ToString() + "%)"; progressBar2.Value = int.Parse(Math.Truncate(percentage).ToString()); } }