问题
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.
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.
Thanks in advance.
回答1:
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.
You could choose to use SHBrowseForFolder
directly, or you could use a different pre-made managed wrapper around it, such as FolderBrowserDialogEx.
回答2:
AFAK there is no built-in control in windows for doing such thing. You have do it yourself using a treeview control and iterating through all your nested folders
here A Simple WPF Explorer Tree you can find an example on how you can do this
来源:https://stackoverflow.com/questions/24695513/wpf-savefiledialog-that-permits-selection-of-folder-not-just-file