public void DownloadFile(string urlAddress, string location) { using (webClient = new WebClient()) { webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged); Uri URL = urlAddress.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ? new Uri(urlAddress) : new Uri("http://" + urlAddress); try { webClient.DownloadFileAsync(URL, location); } catch (Exception ex) { MessageBox.Show(ex.Message + " " + URL); } } void ProgressChanged(object sender, DownloadProgressChangedEventArgs e) { downloadProgress.Value = e.ProgressPercentage; LdownloadProgress.Text = e.ProgressPercentage.ToString() + "%"; } void Completed(object sender, AsyncCompletedEventArgs e) { if (e.Error != null) { string error = e.Error.ToString(); MessageBox.Show(error); return; } if (e.Cancelled == true) { MessageBox.Show("Download has been canceled."); } else { // Alert on download complete MessageBox.Show("Client Downloaded Please wait for Install Confirmation!"); // Run Intall function with textbox input to update config file and extract game files Launcher.InstallGame(installPath.Text.ToString()); /* * TODO: * Create function [DeleteSetup()] to Delete Setup File after install. * Launcher.DeleteSetup(); * */ // Alert on Completion MessageBox.Show("TCoS Installed Successfully!"); } } }