0

我如何使用文件夹浏览器对话框?

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

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
            {

            }
        }

我该怎么做 ?

4

2 回答 2

6

像这样的东西?

using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        string path = dialog.SelectedPath;
    }
}
于 2013-08-03T19:19:33.873 回答
1
DialogResult result = openFileDialog1.ShowDialog();
  if (result == DialogResult.OK) 
   {
    // Test result.
   }
于 2013-08-03T19:28:28.980 回答