Dapplo.Windows.Dialogs
3.19.3
Prefix Reserved
dotnet add package Dapplo.Windows.Dialogs --version 3.19.3
NuGet\Install-Package Dapplo.Windows.Dialogs -Version 3.19.3
<PackageReference Include="Dapplo.Windows.Dialogs" Version="3.19.3" />
<PackageVersion Include="Dapplo.Windows.Dialogs" Version="3.19.3" />
<PackageReference Include="Dapplo.Windows.Dialogs" />
paket add Dapplo.Windows.Dialogs --version 3.19.3
#r "nuget: Dapplo.Windows.Dialogs, 3.19.3"
#:package Dapplo.Windows.Dialogs@3.19.3
#addin nuget:?package=Dapplo.Windows.Dialogs&version=3.19.3
#tool nuget:?package=Dapplo.Windows.Dialogs&version=3.19.3
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.19.3)
-
net10.0-windows7.0
- Dapplo.Windows.Common (>= 3.19.3)
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.19.3 | 96 | 11/2/2026 |
| 3.18.5 | 87 | 11/2/2026 |
| 3.17.3 | 98 | 10/19/2026 |
| 3.16.2 | 97 | 10/18/2026 |
| 3.15.2 | 98 | 10/17/2026 |
| 3.14.4 | 100 | 10/11/2026 |
| 3.14.2 | 101 | 10/10/2026 |
| 3.13.5 | 96 | 10/10/2026 |
| 3.12.2 | 95 | 10/9/2026 |
| 3.11.2 | 89 | 10/9/2026 |
| 3.10.5 | 95 | 10/9/2026 |
| 3.10.3 | 95 | 10/9/2026 |
| 3.9.2 | 94 | 10/8/2026 |
| 3.8.2 | 98 | 10/8/2026 |
| 3.7.2 | 96 | 10/8/2026 |
| 3.6.8 | 95 | 10/8/2026 |
| 3.6.3 | 84 | 10/8/2026 |
| 3.5.3 | 92 | 10/8/2026 |
| 3.4.2 | 89 | 10/8/2026 |
| 3.3.5 | 90 | 10/8/2026 |