让用户选择C#中的子目录的最佳方法是什么?

例如,一个允许用户整理所有保存的html收据的应用。他最有可能希望能够选择一个根子目录,程序应在该根子目录中搜索已保存的网页(收据)。

重复:


Browse for a directory in C#

最佳答案

Folder Browser Dialog是必经之路。

如果要设置初始文件夹路径,可以将其添加到表单加载事件中:

// Sets "My Documents" as the initial folder path
string myDocsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
FolderBrowserDialog1.SelectedPath = myDocsPath;

10-01 17:38