SaveFileDialog允许选择文件夹

SaveFileDialog允许选择文件夹

本文介绍了WPF SaveFileDialog允许选择文件夹,而不仅仅是文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个类似SaveFileDialog的控件,该控件允许我选择 目录 而不是文件.它还应该让我通过粘贴文本来指定目录. SaveFileDialog不允许这样做.

I need a control like SaveFileDialog that lets me choose a directory instead of a file. It should also let me specify the directory by pasting text. SaveFileDialog does not allow this.

我尝试过FolderBrowserDialog,但是它不符合我的要求,因为它不支持将目录路径粘贴为文本.我正在使用的某些目录可能嵌套了10个或更多级别,因此被迫通过点击导航是不够的.

I have tried FolderBrowserDialog, but it does not meet my requirements because it does not support pasting the directory path as text. Some of the directory I'm working with may be nested 10 levels or more, so being forced to navigate via point-and-click is not enough.

谢谢.

推荐答案

FolderBrowserDialog本身可能不支持此功能,但是它是支持该功能的shell函数的精简包装. SHBrowseForFolder 函数的 BROWSEINFO 参数中有一个标志BIF_EDITBOX可以满足您的要求.

FolderBrowserDialog itself may not support this, but it's a thin wrapper around a shell function that does support it. The SHBrowseForFolder function's BROWSEINFO parameter has a flag BIF_EDITBOX that does what you want.

您可以选择直接使用SHBrowseForFolder,也可以在其周围使用其他预制的托管包装,例如 FolderBrowserDialogEx .

You could choose to use SHBrowseForFolder directly, or you could use a different pre-made managed wrapper around it, such as FolderBrowserDialogEx.

这篇关于WPF SaveFileDialog允许选择文件夹,而不仅仅是文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 09:47