public void DownloadUpdateAsync() { if (_downloadUpdateWebClient != null) { throw new InvalidOperationException("A previous call to DownloadUpdateAsync() is still in progress."); } if (_currentUpdateInfo == null || !_currentUpdateInfo.IsValid) { throw new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync()."); } #if !PORTABLE _currentUpdateInfo.UpdateFilePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "exe")); #else var sfd = new SaveFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), FileName = _currentUpdateInfo.FileName, RestoreDirectory = true }; if (sfd.ShowDialog() == DialogResult.OK) { _currentUpdateInfo.UpdateFilePath = sfd.FileName; } else { return; } #endif DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress, _currentUpdateInfo.UpdateFilePath); }
public void DownloadUpdateAsync() { if (_downloadUpdateWebClient != null) { throw (new InvalidOperationException("A previous call to DownloadUpdateAsync() is still in progress.")); } if (_currentUpdateInfo == null || !_currentUpdateInfo.IsValid) { throw (new InvalidOperationException("CurrentUpdateInfo is not valid. GetUpdateInfoAsync() must be called before calling DownloadUpdateAsync().")); } _currentUpdateInfo.UpdateFilePath = Path.Combine(Path.GetTempPath(), Path.ChangeExtension(Path.GetRandomFileName(), "exe")); DownloadUpdateWebClient.DownloadFileAsync(CurrentUpdateInfo.DownloadAddress, _currentUpdateInfo.UpdateFilePath); }