我如何使用folderbrowserdialog?

时间:2013-08-03 18:57:59

标签: c# winforms openfiledialog

我如何使用folderbrowserdialog?

我希望用户能够选择他想要的任何目录。

private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                DialogResult result1;
                result1 = new DialogResult();
                folderBrowserDialog1. = "Select New Folder To Collect Files";
                if (result1 == DialogResult.OK)
                {

                }
                else
                {

                }
            }
            else
            {

            }
        }

我该怎么做?

2 个答案:

答案 0 :(得分:6)

这样的东西?

using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        string path = dialog.SelectedPath;
    }
}

答案 1 :(得分:0)

DialogResult result = openFileDialog1.ShowDialog();
  if (result == DialogResult.OK) 
   {
    // Test result.
   }