Using folder browser dialog in Visual C# 2005 express edition

Using folder browser dialog in Visual C# 2005 express edition

Create a windows application and add the folder browser dialog from the toolbox to the form and then add one textbox and a button to the form. Inorder to select a folder from the system use the selectedpath property of the folder browser dialog to get the path of the folder selected. This is retrieved by checking the FolderBrowserDialog component’s DialogResult property to see how the dialog box was closed and get the value of the FolderBrowserDialog component’s SelectedPath property.

sample code:

Inside the button1 click event write the following code.

private void button1_Click(object sender, EventArgs e)
 {
   if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
   {
 

 textBox1.Text=folderBrowserDialog1.SelectedPath.Trim();

   }
 }

Clicking the button will show the dialog from which the folder can be browsed and selected and then click ok to add the selected path to the textbox.

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.