Geeks With Blogs
Hesham Elsaghir Senoior Design Engineer

I am writting these programs in C# "C Sharp" and always needed to give the user the option to select a folder.  Well, this should not be a segnificant task.  Dialog folders are always been provided by the toolbox in Visual Studio, Open, Save, Print, Font, etc...  so the Folder Browser should not be an issue.  So, I spent all day looking for a way to give the user the option to select a folder in my program.  search all over the internet and all blogs.  found a lot of feed back, but wow, that was so much to do to add this little option to my program.   So finally I look in my toolbox components and I saw it.  the Folderbrowserdialog component.  it is there.

all you have to do is add this to a button click: 

if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
Selected_Folder_Button.Text = folderBrowserDialog1.SelectedPath;
}

I can not believe all that talk out there on the internet and complecated feed back, this is two lines of code!!!!

Posted on Thursday, March 26, 2009 2:30 PM C# , MS Windows | Back to top


Comments on this post: How to Add Folder Browser Dialog Option to Your C# CSharp Program

# re: Folder Browser Dialog
Requesting Gravatar...
thanks for putting this up, had a lot of trouble finding a simple answer too, didnt know all I had to do was double click the folderbrowser in the toolbox then put t^hat code in, : )
thank you
Left by Nick on Feb 23, 2010 12:49 PM

# re: How to Add Folder Browser Dialog Option to Your C# CSharp Program
Requesting Gravatar...
The problem is that this opens a altogether ifferent dialog. To see the files/folders on your original form, you need to place controls like Shell MegaPack (http://www.ssware.com/megapack.htm) on the form.
Left by G. Himangi on Feb 22, 2011 11:55 PM

Your comment:
 (will show your gravatar)


Copyright © heshamelsaghir | Powered by: GeeksWithBlogs.net