private string ChooseFolder() { var dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true; CommonFileDialogResult result = dialog.ShowDialog(); if (result.Equals(CommonFileDialogResult.Ok)) { return(dialog.FileName); } return(null); }
private void searchFolderButton(object sender, RoutedEventArgs e) { string actualBackupFolder = FolderTextBlock.Text; CommonOpenFileDialog dialog = new CommonOpenFileDialog(); dialog.IsFolderPicker = true; //show actual backup folder or "C:\" if (actualBackupFolder == null || actualBackupFolder.Length <= 0) { actualBackupFolder = @"C:\"; } dialog.InitialDirectory = actualBackupFolder; CommonFileDialogResult result = dialog.ShowDialog(); //ok pressed if (result.Equals(CommonFileDialogResult.Ok)) { FolderTextBlock.Text = dialog.FileName; } }