using Microsoft.WindowsAPICodePack.Dialogs; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WpfApp1 { public static class FolderHelper { /// /// 打开目录选择对话框,返回选择的路径。取消则返回 null。 /// public static string? SelectFolder(string title = "请选择保存目录") { var dialog = new CommonOpenFileDialog { IsFolderPicker = true, Title = title }; if (dialog.ShowDialog() == CommonFileDialogResult.Ok) { return dialog.FileName; } return null; } } }