使用FolderBrowserDialog选择目录。内含设置初始目录的功能
// (C) Copyright 2021 by 鸟哥
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NG.IO
{
public class DirectoryUtil
{
/// <summary>
/// 提示用户选择一个文件夹
/// </summary>
/// <param name="initPath">初始文件夹</param>
/// <returns></returns>
public static string SelectDir(string initPath)
{
FolderBrowserDialog dlg = new FolderBrowserDialog();
dlg.SelectedPath = initPath;
dlg.ShowDialog();
return dlg.SelectedPath;
}
}
}