FolderBrowserEx 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package FolderBrowserEx --version 1.0.0                
NuGet\Install-Package FolderBrowserEx -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FolderBrowserEx" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FolderBrowserEx --version 1.0.0                
#r "nuget: FolderBrowserEx, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FolderBrowserEx as a Cake Addin
#addin nuget:?package=FolderBrowserEx&version=1.0.0

// Install FolderBrowserEx as a Cake Tool
#tool nuget:?package=FolderBrowserEx&version=1.0.0                

FolderBrowserEx

NuGet .NET Core

FolderBrowserEx is a library to use the Windows Vista/7 Folder Browser in your .NET Framework and .NET Core Applications.

Supporting .NET Framework (4.5+) and .NET Core (3.0 and 3.1)

Table of contents

Introduction

In both .NET Framework and .NET Core applications we can use the control FolderBrowserDialog from System.Windows.Form. The problem is that the style of this controls looks very old and is very difficult to use, especially when it is compared to the new folder selection dialog which is used in Windows Vista. Unfortunately, it has not been included to .NET.

The aim of this project is to offer a Windows Vista look and feel folder browser dialog to easily give a more modern look to our .NET applications.

Getting Started

To use this library, there are a few options:

The FolderBrowserDialog uses the IFolderBrowserDialog interface.

public interface IFolderBrowserDialog
{
    /// <summary>
    /// Gets/sets the title of the dialog
    /// </summary>
    string Title { get; set; }

    /// <summary>
    /// Gets/sets folder in which dialog will be open.
    /// </summary>
    string InitialFolder { get; set; }

    /// <summary>
    /// Gets/sets directory in which dialog will be open 
    /// if there is no recent directory available.
    /// </summary>
    string DefaultFolder { get; set; }

    /// <summary>
    /// Gets selected folder.
    /// </summary>
    string SelectedFolder { get; }

    /// <summary>
    /// Shows the folder browser dialog with a the default owner
    /// </summary>
    /// <returns>
    /// System.Windows.Forms.DialogResult.OK if the user clicks OK in the dialog box;
    /// otherwise, System.Windows.Forms.DialogResult.Cancel.
    /// </returns>
    DialogResult ShowDialog();

    /// <summary>
    /// Shows the folder browser dialog with a the specified owner
    /// </summary>
    /// <param name="owner">Any object that implements IWin32Window to own the folder browser dialog</param>
    /// <returns>
    /// System.Windows.Forms.DialogResult.OK if the user clicks OK in the dialog box;
    /// otherwise, System.Windows.Forms.DialogResult.Cancel.
    /// </returns>
    DialogResult ShowDialog(IWin32Window owner);
    void Dispose();
}

To use in an application, you can follow this example code. There are others examples in the directory Samples of the solution.

FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()
folderBrowserDialog.Title = "Select a folder";
folderBrowserDialog.InitialFolder = @"C:\";
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
  string result += folderBrowserDialog.SelectedFolder;
}

If you want to use the FolderBrowserEx library from a View Model, follow this example code.

using FolderBrowserEx;
using MVVMBase;
using System.Windows.Forms;
using System.Windows.Input;

namespace NetFrameworkSample
{
    public class MainWindowViewModel : ViewModelBase
    {
        private readonly IFolderBrowserDialog _folderBrowserDialog;
        private string _result;

        public MainWindowViewModel(IFolderBrowserDialog folderBrowserDialog)
        {
            _folderBrowserDialog = folderBrowserDialog;
            ShowFolderBrowserCommand = new Command(ShowFolderBrowserCommandExecute, ShowFolderBrowserCommandCanExecute);
        }

        public ICommand ShowFolderBrowserCommand { get; private set; }

        public string Result
        { 
            get { return _result; }
            set { _result = value; OnPropertyChanged(); }
        }

        private bool ShowFolderBrowserCommandCanExecute()
        {
            return true;
        }

        private void ShowFolderBrowserCommandExecute()
        {
            _folderBrowserDialog.Title = "Select a folder";
            _folderBrowserDialog.InitialFolder = @"C:\";
            if (_folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                Result += $"{_folderBrowserDialog.SelectedFolder}\n";
            }
        }
    }
}

License

Copyright © 2020 Evaristo Cuesta

FolderBrowserEx is provided as-is under the MIT license. For more information see LICENSE.

Credits

This project was adapted from the code from CodeProject writen by ftwnate917 and improved with new features.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 is compatible.  netcoreapp3.1 is compatible. 
.NET Framework net452 is compatible.  net46 is compatible.  net461 was computed.  net462 was computed.  net463 was computed.  net47 is compatible.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.0

    • No dependencies.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FolderBrowserEx:

Package Downloads
MessageDialogManagerLib

Library to easily use dialogs from a View Model in Mahapps.Metro applications.

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on FolderBrowserEx:

Repository Stars
BedrockLauncher/BedrockLauncher
atenfyr/UAssetGUI
A tool designed for low-level examination and modification of Unreal Engine game assets by hand.
Version Downloads Last updated
1.0.1 26,779 12/18/2020
1.0.0 1,332 11/5/2020