Browse for a directory in C#

后端 未结 6 627
一向
一向 2020-12-24 10:14

How can I present a control to the user that allows him/her to select a directory?

There doesn\'t seem to be any native .net controls which do this?

6条回答
  •  被撕碎了的回忆
    2020-12-24 11:07

    string folderPath = "";
    FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
    if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) {
        folderPath = folderBrowserDialog1.SelectedPath ;
    }
    

提交回复
热议问题