How to browse for folder

前端 未结 4 1384
灰色年华
灰色年华 2020-12-18 04:30

I want to design a program contain browse button, where we can browse to the selected folder and open the file inside the folder.

I need a reference and reading wher

4条回答
  •  Happy的楠姐
    2020-12-18 05:10

                string folderpath = "";
                FolderBrowserDialog fbd = new FolderBrowserDialog();
    
                fbd.ShowNewFolderButton = false;
                fbd.RootFolder = System.Environment.SpecialFolder.MyComputer;
                DialogResult dr = fbd.ShowDialog();
    
                if (dr == DialogResult.OK)
                {
                    folderpath = fbd.SelectedPath;
                }
    
                if (folderpath != "")
                {
                    txtBoxPath.Text = folderpath; 
                }
    

提交回复
热议问题