使用CommonOpenFileDialog选择目录
// 使用CommonOpenFileDialog选择目录
string destDBDir = Path.Combine(DefaultConfig.SystemConfigs.DataPath, "DB", DateTime.Now.ToString("yyyy-MM-dd"));
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
dialog.Multiselect = false;//该值确定是否可以选择多个文件
dialog.Title = "浏览DB数据存储目录";
dialog.IsFolderPicker = true;
dialog.InitialDirectory = Path.Combine(DefaultConfig.SystemConfigs.DataPath, "DB");
dialog.RestoreDirectory = true;
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
{
destDBDir = dialog.FileName;
}
// 使用FolderBrowserDialog 选择目录
// 使用FolderBrowserDialog 选择目录
string destDBDir = string.Empty;
FolderBrowserDialog fbd = new FolderBrowserDialog();
fbd.RootFolder = System.Environment.SpecialFolder.MyComputer;
fbd.ShowNewFolderButton = true;
fbd.SelectedPath = Path.Combine(DefaultConfig.SystemConfigs.DataPath, "DB", DateTime.Now.ToString("yyyy-MM-dd"));
fbd.Description = "请选择DB存储目录:";
if (fbd.ShowDialog() == DialogResult.OK)
{
destDBDir = fbd.SelectedPath.ToString();
}