public async void DownloadInstaller() { const string Url = @"http://www.mapwindow.org/dokuwiki-2011-05-25a.tgz"; var filename = Path.GetTempFileName(); Debug.WriteLine(filename); await DownloadHelper.DownloadBinaryAsync(Url, filename); var fileInfo = new FileInfo(filename); Debug.WriteLine("File size: " + fileInfo.Length); Assert.IsTrue(fileInfo.Length > 0); Debug.WriteLine("Saved as " + filename); }
/// <summary> /// Start method to download a possible newer version /// </summary> private static async void DownloadNewerVersion() { // TODO: Needs modifications. For now, skip: return; Logger.Current.Debug("Checking for new version"); var assembly = Assembly.GetExecutingAssembly(); var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); Logger.Current.Debug("File version: {0}", fileVersionInfo.FileVersion); var processorArchitecture = assembly.GetName().ProcessorArchitecture; if (processorArchitecture == ProcessorArchitecture.Amd64 || processorArchitecture == ProcessorArchitecture.IA64) { _isx64 = true; Logger.Current.Debug("x64 version"); } // Download json-file which will hold the version numbers and download url of the available versions. const string JsonLocation = @"http://www.mapwindow.org/mw5-update.json"; var result = await DownloadHelper.DownloadSerializedJSONDataAsync <Dictionary <string, InstallerInfo> >(JsonLocation); if (result == null || result.Count == 0) { Logger.Current.Warn("Couldn't get mw5-update.json. Do you have a working Internet connection?"); return; } string downloadUrl; string installerName; // Check stable version: if (CheckVersions(result, _isx64, "Stable", fileVersionInfo, out downloadUrl, out installerName)) { // Download installer var filename = Path.Combine(Path.GetTempPath(), installerName); AppConfig.Instance.UpdaterInstallername = filename; AppConfig.Instance.UpdaterIsDownloading = true; await DownloadHelper.DownloadBinaryAsync(downloadUrl, filename); AppConfig.Instance.UpdaterIsDownloading = false; // Set install flag AppConfig.Instance.UpdaterHasNewInstaller = true; // Got newest stable version, stop looking for beta installer; return; } // Check beta version: if (CheckVersions(result, _isx64, "Beta", fileVersionInfo, out downloadUrl, out installerName)) { // Download installer var filename = Path.Combine(Path.GetTempPath(), installerName); AppConfig.Instance.UpdaterInstallername = filename; AppConfig.Instance.UpdaterIsDownloading = true; await DownloadHelper.DownloadBinaryAsync(downloadUrl, filename); AppConfig.Instance.UpdaterIsDownloading = false; // Set install flag AppConfig.Instance.UpdaterHasNewInstaller = true; return; } Logger.Current.Debug("No new installers available"); }