private void SelectVolume_Click(object sender, RoutedEventArgs e) { _usnEntryDetail.Visibility = Visibility.Hidden; resultsLb.ItemsSource = null; resultsLb.Items.Clear(); VolumeSelectDialog selectVolumeDlg = new VolumeSelectDialog(this); bool?rtn = selectVolumeDlg.ShowDialog(); if (rtn != null && rtn.Value) { DriveInfo volume = selectVolumeDlg.Volume; try { _usnJournal = new NtfsUsnJournal(volume); FunctionElapsedTime.Content = string.Format("{0} elapsed time {1}(ms) - Volume: {2}", "NtfsUsnJournal() constructor", NtfsUsnJournal.ElapsedTime.Milliseconds.ToString(), volume.Name); QueryUsnJournal.IsEnabled = true; CreateUsnJournal.IsEnabled = true; DeleteUsnJournal.IsEnabled = true; SaveUsnState.IsEnabled = true; ViewUsnChanges.IsEnabled = true; ListFiles.IsEnabled = true; ListFolders.IsEnabled = true; } catch (Exception excptn) { if (excptn.Message.Contains("Access is denied")) { ListBoxItem lbItem = new ListBoxItem(); lbItem.Content = string.Format("'Access Denied' exception caught attempting to select volume. \nYou need 'Admin' rights to run this application."); lbItem.Foreground = Brushes.Red; resultsLb.Items.Add(lbItem); } else { ListBoxItem lbItem = new ListBoxItem(); lbItem.Content = string.Format("{0} exception caught attempting to select volume. \n{1}", excptn.GetType().ToString(), excptn.Message); lbItem.Foreground = Brushes.Red; resultsLb.Items.Add(lbItem); } } } else { ListBoxItem lbItem = new ListBoxItem(); lbItem.Content = string.Format("Select Volume -- No Volume Selected"); lbItem.Foreground = Brushes.Red; resultsLb.Items.Add(lbItem); } }
private void SelectVolume_Click(object sender, RoutedEventArgs e) { e.Handled = true; _usnEntryDetail.Visibility = Visibility.Hidden; resultsLb.ItemsSource = null; resultsLb.Items.Clear(); var selectVolumeDlg = new VolumeSelectDialog(this); var rtn = selectVolumeDlg.ShowDialog(); if (null != rtn && rtn.Value) { var driveInfo = selectVolumeDlg.Volume; try { Journal = new NtfsUsnJournal(driveInfo); FunctionElapsedTime.Content = string.Format(CultureInfo.InvariantCulture, "{0} duration: {1} (ms) - Volume: {2}", "NtfsUsnJournal constructor", NtfsUsnJournal.ElapsedTime.TotalMilliseconds, driveInfo.Name); QueryUsnJournal.IsEnabled = true; CreateUsnJournal.IsEnabled = true; DeleteUsnJournal.IsEnabled = true; SaveUsnState.IsEnabled = true; ViewUsnChanges.IsEnabled = true; ListFiles.IsEnabled = true; ListFolders.IsEnabled = true; } catch (Exception ex) { if (ex.Message.Contains("Access is denied")) { var lbItem = new ListBoxItem { Content = "\'Access Denied\' exception caught attempting to select volume. \nYou need \'Admin\' rights to run this application.", Foreground = Brushes.Red }; resultsLb.Items.Add(lbItem); } else { var lbItem = new ListBoxItem { Content = string.Format(CultureInfo.InvariantCulture, "{0} exception caught attempting to select volume. \n{1}", ex.GetType(), ex.Message), Foreground = Brushes.Red }; resultsLb.Items.Add(lbItem); } } } else { var lbItem = new ListBoxItem { Content = "Select Volume -- No Volume Selected", Foreground = Brushes.Red }; resultsLb.Items.Add(lbItem); } }