Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/evaristocuesta/folderbrowserex
FolderBrowserEx is a library to use the Windows Vista/7 Folder Browser in your .NET Framework and .NET Core Applications.
https://github.com/evaristocuesta/folderbrowserex
browser classlibrary csharp csharp-library dialog folder folderbrowserdialog mvvm netcore netframework vista windows windows-7 windows-vista wpf
Last synced: 4 months ago
JSON representation
FolderBrowserEx is a library to use the Windows Vista/7 Folder Browser in your .NET Framework and .NET Core Applications.
- Host: GitHub
- URL: https://github.com/evaristocuesta/folderbrowserex
- Owner: evaristocuesta
- License: mit
- Created: 2020-11-04T21:41:29.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-26T17:34:00.000Z (over 3 years ago)
- Last Synced: 2024-10-11T14:20:37.185Z (4 months ago)
- Topics: browser, classlibrary, csharp, csharp-library, dialog, folder, folderbrowserdialog, mvvm, netcore, netframework, vista, windows, windows-7, windows-vista, wpf
- Language: C#
- Homepage: https://www.nuget.org/packages/FolderBrowserEx/
- Size: 123 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FolderBrowserEx
[![NuGet](https://img.shields.io/nuget/v/FolderBrowserEx)](https://nuget.org/packages/FolderBrowserEx/) [![Downloads](https://img.shields.io/nuget/dt/FolderBrowserEx)](https://nuget.org/packages/FolderBrowserEx/) [![.NET Core](https://github.com/evaristocuesta/FolderBrowserEx/workflows/.NET%20Core/badge.svg)](https://github.com/evaristocuesta/FolderBrowserEx/actions) [![Languages](https://img.shields.io/github/languages/top/evaristocuesta/FolderBrowserEx)](https://github.com/evaristocuesta/FolderBrowserEx/) [![License](https://img.shields.io/github/license/evaristocuesta/FolderBrowserEx)](https://raw.githubusercontent.com/evaristocuesta/FolderBrowserEx/master/LICENSE) [![Author](https://img.shields.io/badge/author-Evaristo%20Cuesta-blue)](https://www.evaristocuesta.com/)**FolderBrowserEx** is a library to use the Windows Vista/7 Folder Browser in your .NET Framework and .NET Core Applications with which you can be able to select multiple folders.
Supporting .NET Framework (4.5+) and .NET Core (3.0 and 3.1)
![Game Screenshot](./Resources/Screenshot-01.JPG)
## Table of contents
- [Introduction](#introduction)
- [Getting Started](#getting-started)
- [License](#license)
- [Credits](#credits)## 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 and with which you can be able to select multiple folders.
## Getting Started
To use this library, there are a few options:
- Download the [Github repository](https://github.com/evaristocuesta/FolderBrowserEx)
- Use the [FolderBrowserEx Nuget Package](https://nuget.org/packages/FolderBrowserEx/)The FolderBrowserDialog uses the IFolderBrowserDialog interface.
```csharp
public interface IFolderBrowserDialog
{
///
/// Gets/sets the title of the dialog
///
string Title { get; set; }///
/// Gets/sets folder in which dialog will be open.
///
string InitialFolder { get; set; }///
/// Gets/sets directory in which dialog will be open
/// if there is no recent directory available.
///
string DefaultFolder { get; set; }///
/// Gets selected folder when AllowMultiSelect is false
///
string SelectedFolder { get; }///
/// Gets selected folders when AllowMultiSelect is true.
///
List SelectedFolders { get; }bool AllowMultiSelect { get; set; }
///
/// Shows the folder browser dialog with a the default owner
///
///
/// System.Windows.Forms.DialogResult.OK if the user clicks OK in the dialog box;
/// otherwise, System.Windows.Forms.DialogResult.Cancel.
///
DialogResult ShowDialog();///
/// Shows the folder browser dialog with a the specified owner
///
/// Any object that implements IWin32Window to own the
/// folder browser dialog
///
///
/// System.Windows.Forms.DialogResult.OK if the user clicks OK in the dialog box;
/// otherwise, System.Windows.Forms.DialogResult.Cancel.
///
DialogResult ShowDialog(IWin32Window owner);///
/// Dispose the object
///
void Dispose();
}
```
To use in an application, you can follow this example code. There are others examples in the directory Samples of the solution.```csharp
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()
folderBrowserDialog.Title = "Select a folder";
folderBrowserDialog.InitialFolder = @"C:\";
folderBrowserDialog.AllowMultiSelect = false;
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.
```csharp
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 multiple folders";
_folderBrowserDialog.InitialFolder = @"C:\";
_folderBrowserDialog.AllowMultiSelect = false;
if (_folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
Result += $"{_folderBrowserDialog.SelectedFolder}\n";
}
}
}
}
```## License
Copyright © 2021 Evaristo Cuesta
**FolderBrowserEx** is provided as-is under the MIT license. For more information see [LICENSE](https://github.com/evaristocuesta/FolderBrowserEx/blob/master/LICENSE).
## Credits
This project was adapted from the code from [CodeProject](https://www.codeproject.com/Articles/5255769/Csharp-Select-FolderDialog-for-NET-Core-3-0) writen by [ftwnate917](https://www.codeproject.com/Members/ftwnate917) and improved with new features.