C# 选择文件夹
1 /// <summary> 2 /// 选择文件夹 3 /// </summary> 4 /// <returns></returns> 5 public static string SelectFolder() 6 { 7 string foldePath = string.Empty; 8 try 9 { 10 CommonOpenFileDialog dialog = new CommonOpenFileDialog(); 11 dialog.IsFolderPicker = true; 12 dialog.Title = "选择文件夹"; 13 dialog.Multiselect = false; 14 dialog.RestoreDirectory = true; 15 if (dialog.ShowDialog() == CommonFileDialogResult.Ok) 16 { 17 foldePath = dialog.FileName; 18 } 19 return foldePath; 20 } 21 catch (Exception ex) 22 { 23 throw ex; 24 } 25 }
依赖
Microsoft.WindowsAPICodePack.Dialogs

浙公网安备 33010602011771号