public static bool DownloadFileMonoLinux(string fileToDownload, string savePath, string userAgent = "") { Console.WriteLine("Downloading " + fileToDownload); string userAgentFormatted = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"; if (userAgent != "") { userAgentFormatted = '"' + userAgent + '"'; } ReadProcessOutput("wget", @"--user-agent=" + userAgentFormatted + " -O " + DragonUtil.SurroundWithQuotes(savePath) + " " + fileToDownload); return(File.Exists(savePath)); }
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); }
private static void RunCoreUpdater(string updaterFolder, string zipPath) { Console.WriteLine("Starting updater process..."); ProcessStartInfo processInfo = new ProcessStartInfo() { ErrorDialog = true, UseShellExecute = true }; if (DragonUtil.IsRunningPortable()) { processInfo.FileName = "dotnet"; //processInfo.Arguments = "dotnet'"; processInfo.Arguments += DragonUtil.SurroundWithQuotes(updaterFolder + "/CoreUpdater.dll"); } else { if (DragonUtil.CurrentOperatingSystem.IsWindows()) { processInfo.FileName = DragonUtil.SurroundWithQuotes(updaterFolder + "/CoreUpdater.exe"); } else if (DragonUtil.CurrentOperatingSystem.IsMacOS()) { processInfo.FileName = DragonUtil.SurroundWithQuotes(updaterFolder + "/CoreUpdater"); } else if (DragonUtil.CurrentOperatingSystem.IsLinux()) { processInfo.FileName = DragonUtil.SurroundWithQuotes(updaterFolder + "/CoreUpdater"); } } processInfo.Arguments += " " + DragonUtil.SurroundWithQuotes(DragonUtil.CurrentDirectory) + " " + DragonUtil.SurroundWithQuotes(zipPath); Console.WriteLine(processInfo.FileName + processInfo.Arguments); Process process = new Process { StartInfo = processInfo }; process.Start(); }