private static GithubRelease GetNewestReleaseMono() { string outputFilePath = Application.StartupPath + @"/release.json"; GithubRelease rel = null; if (File.Exists(Application.StartupPath + "/release.json")) { File.Delete(Application.StartupPath + "/release.json"); } MonoHelper.DownloadFile( "https://api.github.com/repos/BlackDragonBE/MarkdownToRW_Converter/releases/latest", outputFilePath, "MarkdownToRW_Converter"); // Read json if (File.Exists(Application.StartupPath + "/release.json")) { var json = ""; using (StreamReader sr = new StreamReader(outputFilePath.Replace("\"", ""))) { json = sr.ReadToEnd(); } rel = JsonConvert.DeserializeObject <GithubRelease>(json); File.Delete(Application.StartupPath + "/release.json"); } return(rel); }
private static void StartAppUpdate(GithubRelease newestRelease) { // Copy updater.exe to folder above // Run updater.exe on folder above // Updater gets current folder & path to zip as arguments & starts // This app exists // Preparation Console.WriteLine("Downloading new release..."); string downloadUrl = ""; string downloadName = ""; foreach (GithubRelease.Asset asset in newestRelease.assets) { if (asset.name.Contains("GUI")) { downloadName = asset.name; downloadUrl = asset.browser_download_url; } } string zipPath = Directory.GetParent(Application.StartupPath) + "/" + downloadName; string newUpdaterPath = Directory.GetParent(Application.StartupPath) + "/RWUpdater.exe"; //Download update MonoHelper.DownloadFile(downloadUrl, zipPath, "MarkdownToRW_Converter"); // Copy updater to folder above if (File.Exists(newUpdaterPath)) { File.Delete(newUpdaterPath); } File.Copy(Application.StartupPath + "/RWUpdater.exe", newUpdaterPath); File.Copy(Application.StartupPath + "/DotNetZip.dll", Directory.GetParent(Application.StartupPath) + "/DotNetZip.dll"); // Run updater & quit Process.Start(newUpdaterPath, DragonUtil.SurroundWithQuotes(Application.StartupPath) + " " + DragonUtil.SurroundWithQuotes(zipPath)); Environment.Exit(0); }