top of page

how to create an open file dialog to select folder


ever wonder how to create an open file dialog that can select files? well wonder no more because here i'm going to show you how to create an open file dialog to select a folder.

now these kind of open file dialog are a bit rare to come by mostly because little do people know how to implement and use it.


the tutorial video:

if you don't want to watch it then read these steps:


step #1: create a new C#.net framework project for this tutorial we are going to use the venerable visual studio. because the visual studio is a global standard ide tool.


step #2: Add a textbox and a button

Step #3: right-click at your C# program and click 'manage NuGet package'


Step #4: search 'Microsoft.WindowsAPICodePack-Shell' on the NuGet package manager

after you find it, install it


Step #5: add this code:

using Microsoft.WindowsAPICodePack.Dialogs;

on your project


Step #6: double-click your button and add this code:

CommonOpenFileDialog dialog = new CommonOpenFileDialog();
            dialog.IsFolderPicker = true;
            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                textBox1.Text.Text = dialog.FileName;
            }

and now you are done.


Result:











10 views0 comments
bottom of page