コード例 #1
0
        private string ChooseFolder()
        {
            var dialog = new CommonOpenFileDialog();

            dialog.IsFolderPicker = true;
            CommonFileDialogResult result = dialog.ShowDialog();

            if (result.Equals(CommonFileDialogResult.Ok))
            {
                return(dialog.FileName);
            }
            return(null);
        }
コード例 #2
0
        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;
            }
        }