folderbrowserdialog selectedpath不返回任何值

时间:2015-03-23 20:00:49

标签: c# folderbrowserdialog

private void button3_Click(object sender, EventArgs e)
{
    FolderBrowserDialog folderfinder = new FolderBrowserDialog();
    folderfinder.Description = "Select Folder";
    folderfinder.RootFolder = Environment.SpecialFolder.MyComputer;
    folderfinder.ShowNewFolderButton = false;

    Console.Write(folderfinder.SelectedPath);
}

以下代码始终返回""对于选定路径。有谁看到这里有什么问题?我用google搜索过,没有人提到有一个问题,选择路径没有返回任何值。

1 个答案:

答案 0 :(得分:0)

您应该显示对话框(msdn):

if (folderfinder.ShowDialog() == DialogResult.OK)
{
    Console.Write(folderfinder.SelectedPath);
}