Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi All,

In button click i need to open dialog to browse a folder to set a path to Textbox controls download something.

In wpf is any built in control is there,

Actual i need to set the path to text once i select the folder.

I am beginner to wpf. please help me on this..
Posted
Updated 27-Jul-20 8:54am

There is no built in control in WPF. You have a couple of options though:

Using folder browser dialogs from WinForms[^]

Using Windows® API Code Pack for Microsoft® .NET Framework[^]

WPF Folder Browser[^] here on CodePorject
 
Share this answer
 
<pre lang="c++">close()
 
Share this answer
 
Comments
Richard Deeming 7-Dec-18 8:50am    
Posting gibberish as a "solution" to a question is a quick way to get yourself banned from the site.
see "https://www.antoniovalentini.com/how-to-handle-file-and-folder-dialog-windows-in-a-wpf-application
 
Share this answer
 
Comments
CHill60 28-Jul-20 5:56am    
He doesn't really suggest anything new compared to the links in Solution 1
Louis T Klauder Jr 28-Jul-20 6:53am    
The difference is that that link points to a NuGet package that provides a simple ready-to-use solution. Minor hitch caught by CHill60 is that it is in a note at the end of that page, that had not yet been passed on by the moderator, as follows:

As of 2020_07_26, there is a NuGet package: Ookii.Dialogs.Wpf.NETCore.
I needed a folder select dialog for a Core 3.1 WPF project.
In Visual Studio I installed that package and doing so added a reference thereto in Dependencies/Packages.
I added: using Ookii.Dialogs;
Then I get the desired behavior with the function:

private void pick_folder_Name_Click( object sender, RoutedEventArgs e )
{
// this is based on https://www.antoniovalentini.com/how-to-handle-file-and- folder-dialog-windows-in-a-wpf-application/

var ookiiDialog = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog( );
if ( ookiiDialog.ShowDialog( ) == true )
root_folder_TextBox.Text = ookiiDialog.SelectedPath;
}

Reply
Your comment is awaiting moderation.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900