private void InstallUpdateBackgroundWorkerDoWork(object sender, DoWorkEventArgs e) { try { IsButtonEnabled = false; if (string.IsNullOrEmpty(UODataPath) || !InstallerHelper.CheckUoPath(UODataPath)) { MessageBox.Show($"'{UODataPath}' doesn't appear to be a valid UO installation path."); return; } InstallerHelper.ValidatePath(InstallPath); ReleaseAsset razor = GitHubHelper.GetLatestRazorVersion(UseRazorPreview).Assets[0]; ReleaseAsset cuo = GitHubHelper.GetLatestClassicUOVersion(UseCUOPreview).Assets[0]; DownloadFile(razor.BrowserDownloadUrl, Path.Combine(InstallPath, razor.Name)); DownloadFile(cuo.BrowserDownloadUrl, Path.Combine(InstallPath, cuo.Name)); ZipArchive razorZip = ZipFile.OpenRead(Path.Combine(InstallPath, razor.Name)); foreach (ZipArchiveEntry entry in razorZip.Entries) { string full = Path.Combine(InstallPath, "Razor", entry.FullName); string dirName = Path.GetDirectoryName(full); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } if (!string.IsNullOrEmpty(Path.GetFileName(full))) { entry.ExtractToFile(full, true); } } if (InstallCUO) { ZipArchive cuoZip = ZipFile.OpenRead(Path.Combine(InstallPath, cuo.Name)); foreach (ZipArchiveEntry entry in cuoZip.Entries) { string full = Path.Combine(InstallPath, entry.FullName); string dirName = Path.GetDirectoryName(full); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } if (!string.IsNullOrEmpty(Path.GetFileName(full))) { entry.ExtractToFile(full, true); } } ClassicUoModel settings = new ClassicUoModel { UltimaOnlineDirectory = UODataPath, IP = ServerHost, Port = Convert.ToInt32(ServerPort), ClientVersion = ClientVersion, Plugins = new[] { Path.Combine(InstallPath, "Razor", "Razor.exe") } }; File.WriteAllText(Path.Combine(InstallPath, "settings.json"), JsonConvert.SerializeObject(settings)); } InstallerHelper.UpdateSetting("InstallPath", InstallPath); InstallerHelper.UpdateSetting("UODataPath", UODataPath); InstallerHelper.UpdateSetting("ServerHost", ServerHost); InstallerHelper.UpdateSetting("ServerPort", ServerPort); InstallerHelper.UpdateSetting("ClientVersion", ClientVersion); if (ShowLaunchDialogCommand.CanExecute(null)) { ShowLaunchDialogCommand.Execute(null); } } catch (Exception ex) { MessageBox.Show($"Unexpected error. {ex.Message}"); } }