Dapplo.Windows.Dialogs
3.14.4
Prefix Reserved
See the version list below for details.
dotnet add package Dapplo.Windows.Dialogs --version 3.14.4
NuGet\Install-Package Dapplo.Windows.Dialogs -Version 3.14.4
<PackageReference Include="Dapplo.Windows.Dialogs" Version="3.14.4" />
<PackageVersion Include="Dapplo.Windows.Dialogs" Version="3.14.4" />
<PackageReference Include="Dapplo.Windows.Dialogs" />
paket add Dapplo.Windows.Dialogs --version 3.14.4
#r "nuget: Dapplo.Windows.Dialogs, 3.14.4"
#:package Dapplo.Windows.Dialogs@3.14.4
#addin nuget:?package=Dapplo.Windows.Dialogs&version=3.14.4
#tool nuget:?package=Dapplo.Windows.Dialogs&version=3.14.4
Dapplo.Windows.Dialogs
The Windows file open, file save and folder picker dialogs (the Common Item Dialog) for .NET, through COM: no Windows
Forms or WPF needed. Targets net480 and net10.0-windows.
This package is part of Dapplo.Windows. Full documentation: File and folder dialogs, changes: changelog.
Namespace: Dapplo.Windows.Dialogs.
Simple API
FileDialog returns null when the user cancels.
// Every FileDialog method returns null when the user cancels
string path = FileDialog.PickFileToOpen(
title: "Open Document",
initialDirectory: Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
filters: new[] { ("Text files", "*.txt"), ("All files", "*.*") });
if (path != null)
{
Console.WriteLine(File.ReadAllText(path));
}
string savePath = FileDialog.PickFileToSave(
title: "Save Screenshot",
suggestedFileName: "screenshot.png",
filters: new[] { ("PNG Image", "*.png"), ("JPEG Image", "*.jpg") },
defaultExtension: "png");
IReadOnlyList<string> files = FileDialog.PickFilesToOpen(filters: new[] { ("Images", "*.png;*.jpg;*.bmp") });
string folder = FileDialog.PickFolder(title: "Select Output Folder");
Builders
FileOpenDialogBuilder, FileSaveDialogBuilder and FolderPickerBuilder return a FileDialogResult with
WasCancelled, SelectedPath and SelectedPaths.
FileDialogResult result = new FileOpenDialogBuilder()
.WithTitle("Open Configuration")
.WithInitialDirectory(@"C:\ProgramData\MyApp")
.AddFilter("Config files", "*.json;*.xml")
.AddFilter("All files", "*.*")
.WithDefaultExtension("json")
// The dialog is modal for this window
.ShowDialog(ownerWindowHandle);
if (result.WasCancelled)
{
return;
}
string configPath = result.SelectedPath;
FileDialogResult result = new FileOpenDialogBuilder()
.WithTitle("Import Images")
.AddFilter("Images", "*.png;*.jpg;*.bmp;*.gif")
.AllowMultipleSelection()
.ShowDialog();
if (!result.WasCancelled)
{
foreach (string file in result.SelectedPaths)
{
Console.WriteLine(file);
}
}
FileDialogResult result = new FileSaveDialogBuilder()
.WithTitle("Export Report")
.WithSuggestedFileName("report.pdf")
.WithDefaultExtension("pdf")
.AddFilter("PDF files", "*.pdf")
.ShowDialog();
if (!result.WasCancelled)
{
Console.WriteLine($"Export to {result.SelectedPath}");
}
FileDialogResult result = new FolderPickerBuilder()
.WithTitle("Select Backup Location")
.WithInitialDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
.ShowDialog();
if (!result.WasCancelled)
{
Console.WriteLine($"Backup to {result.SelectedPath}");
}
string projects = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Projects");
FileDialogResult result = new FileOpenDialogBuilder()
.WithTitle("Open Project")
.AddFilter("Project files", "*.proj")
// Pinned at the top of the navigation pane, only for this dialog
.AddPlace(projects, atTop: true)
.ShowDialog();
Errors and threading
Cancel is not an error. Real failures throw a COMException. The dialogs need an STA thread: the UI thread of
Windows Forms or WPF, [STAThread] on Main of a console application, or a dedicated STA thread. On any other thread
(e.g. Task.Run) ShowDialog throws an InvalidOperationException before any COM object is created.
// The dialog needs an STA thread. UI threads of WinForms and WPF are STA, a console application's Main needs [STAThread],
// from other threads use a dedicated STA thread:
string path = null;
var thread = new Thread(() => path = FileDialog.PickFileToOpen());
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 is compatible. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Dapplo.Windows.Common (>= 3.14.4)
-
net10.0-windows7.0
- Dapplo.Windows.Common (>= 3.14.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.26.3 | 119 | 11/24/2026 |
| 3.25.2 | 131 | 11/22/2026 |
| 3.24.2 | 147 | 11/17/2026 |
| 3.23.3 | 105 | 11/10/2026 |
| 3.22.2 | 101 | 11/10/2026 |
| 3.21.4 | 98 | 11/9/2026 |
| 3.20.3 | 88 | 11/9/2026 |
| 3.19.3 | 116 | 11/2/2026 |
| 3.18.5 | 95 | 11/2/2026 |
| 3.17.3 | 108 | 10/19/2026 |
| 3.16.2 | 105 | 10/18/2026 |
| 3.15.2 | 106 | 10/17/2026 |
| 3.14.4 | 110 | 10/11/2026 |
| 3.14.2 | 109 | 10/10/2026 |
| 3.13.5 | 107 | 10/10/2026 |
| 3.12.2 | 105 | 10/9/2026 |
| 3.11.2 | 101 | 10/9/2026 |
| 3.10.5 | 105 | 10/9/2026 |
| 3.10.3 | 101 | 10/9/2026 |
| 3.9.2 | 101 | 10/8/2026 |