以下示例代码展示如何调用系统的文件夹选择对话框: Private Function SelectFolder(ByVal Describe As String, Optional ByVal ShowNewFolder As Boolean = True) As String Using nOpen As New System.Windows.Forms.FolderBrowserDialog() nOpen.Description = Describe nOpen.ShowNewFolderB
开发中有时会想实现"选择某个文件夹"的效果: 在WPF中,使用Microsoft.Win32.OpenFileDialog只能选择文件,FolderBrowserDialog只能用树型的方式选择文件夹,很不好用. 终于找到一个办法,使用Windows API Code Pack 在VS里打开Package Manager Console后输入Install-Package WindowsAPICodePack-Shell获取包后 就可以像这样打开选择文件夹Dialog了: var di
var dialog = new System.Windows.Forms.FolderBrowserDialog(); System.Windows.Forms.DialogResult result = dialog.ShowDialog(); Using Folder Browser Dialog in WPF
WPF提供了选择文件对话框,但并没有提供选择文件夹的对话框. OpenFileDialog类存在于PresentationFramework.dll程序集. public string SelectFileWpf() { var openFileDialog = new Microsoft.Win32.OpenFileDialog() { Filter = "Text documents (.txt)|*.txt|All files (*.*)|*.*" }; var result =