/// <exception cref="T:System.UnauthorizedAccessException">The caller does not have the required permission.</exception> /// <exception cref="T:System.IO.IOException"><paramref /> is a file name.</exception> /// <exception cref="T:System.IO.DirectoryNotFoundException"> /// The specified savePath is invalid (for example, it is on an /// unmapped drive). /// </exception> /// <exception cref="T:System.ArgumentException"> /// <paramref /> is a zero-length string, contains only white space, or /// contains one or more invalid characters. You can query for invalid characters by using the /// <see cref="M:System.IO.Path.GetInvalidPathChars" /> method. /// </exception> /// <exception cref="T:System.ArgumentNullException"><paramref /> is <see langword="null" />.</exception> /// <exception cref="T:System.IO.PathTooLongException"> /// The specified savePath, file name, or both exceed the system-defined /// maximum length. /// </exception> private void GenerateButton_Click(object sender, RoutedEventArgs e) { var regenerate = RegenerateCheck.IsChecked ?? false; var savePath = PathBox.Text; var dirs = Directory.GetDirectories(savePath); foreach (var sourceDirectory in dirs) { CbrGenerator.GenerateCbrFromDirectory(sourceDirectory, savePath, regenerate); } }
/// <exception cref="T:System.AggregateException"> /// An aggregate exception containing all the exceptions thrown by the /// registered callbacks on the associated <see cref="T:System.Threading.CancellationToken" />. /// </exception> private async void DownloadButton_Click(object sender, RoutedEventArgs e) { try { ProgressBar.Value = 0; DownloadButton.Visibility = Visibility.Collapsed; CancelButton.Visibility = Visibility.Visible; RecreateCancellationTokenSource(); Log("Started"); var savePath = SavePath.Text; var downloadUri = new Uri(SourceTextBox.Text); var directory = await DownloadAsync(savePath, downloadUri, new Progress <DownloadProgressReport>(ProgressHandler), _cancellationTokenSource.Token).ConfigureAwait(true); CbrGenerator.GenerateCbrFromDirectory(directory, savePath, true); } catch (OperationCanceledException) { MessageBox.Show("Download cancelled."); Log("Cancelled"); } catch (TransferExceededException ex) { MessageBox.Show(ex.Message); _cancellationTokenSource.Cancel(); } catch (UriFormatException) { MessageBox.Show("Wrong url format!"); } catch (DirectoryNotFoundException) { } catch (Exception ex) { Log($"Exception during downloading: {ex.Message}"); } finally { DownloadButton.Visibility = Visibility.Visible; CancelButton.Visibility = Visibility.Collapsed; Log("Finished"); } }