I have to create a button with which the user has to choose a folder. I've try with OpenFileDialog, But there I can not select the folder and the folder just open.
This is my code:
 private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog fdlg = new OpenFileDialog();
            fdlg.Title = "C# Corner Open File Dialog";
            fdlg.InitialDirectory = @"D:\dosfiles\ValPoch";
            fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
            fdlg.FilterIndex = 2;
            fdlg.RestoreDirectory = true;
            if (fdlg.ShowDialog() == DialogResult.OK)
            {
                label2.Text = fdlg.FileName;
                label2.Show();
            }
I try with this code, He works perfectly, But I not like the window, who opened, Is too small.
using (FolderBrowserDialog dlg = new FolderBrowserDialog())
            {
                dlg.Description = "Select a folder";
                dlg.SelectedPath = @"D:\dosfiles\ValPoch\";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    label2.Text = dlg.SelectedPath;
                    label2.ForeColor = Color.Red;
                    label2.Show();
                }
            }
How can I fix my code with OpenFileDIalog to select a folder not to open that folder ?
Thank you.