/// <summary> /// Downloads the file. /// </summary> /// <param name="updateDelegate">The update delegate.</param> /// <remarks>Documented by Dev05, 2009-07-15</remarks> public void DownloadFile(ProgressStatusUpdate updateDelegate) { if (File.Exists(localPath)) { int i = 1; while (File.Exists(Path.ChangeExtension(localPath, "_" + i + ".exe"))) { i++; } localPath = Path.ChangeExtension(localPath, "_" + i + ".exe"); } Uri url = new Uri(downloadPath); currentUpdateDelegate = updateDelegate; WebClient client = new WebClient(); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(client_DownloadFileCompleted); client.DownloadFileAsync(url, localPath); MoveFileEx(localPath, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT); }
/// <summary> /// Downloads the file. /// </summary> /// <param name="updateDelegate">The update delegate.</param> /// <remarks>Documented by Dev05, 2009-07-15</remarks> public void DownloadFile(ProgressStatusUpdate updateDelegate) { if (File.Exists(localPath)) { int i = 1; while (File.Exists(Path.ChangeExtension(localPath, "_" + i + ".exe"))) i++; localPath = Path.ChangeExtension(localPath, "_" + i + ".exe"); } Uri url = new Uri(downloadPath); currentUpdateDelegate = updateDelegate; WebClient client = new WebClient(); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(client_DownloadFileCompleted); client.DownloadFileAsync(url, localPath); MoveFileEx(localPath, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT); }