WPF SaveFileDialog that permits selection of folder, not just file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 04:17:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!