首页 > 代码库 > 2016.5.9 文件选择和文件夹选择对话框
2016.5.9 文件选择和文件夹选择对话框
1、文件夹选择
FolderBrowserDialog folderDlg = new FolderBrowserDialog();
folderDlg.ShowNewFolderButton = false;
folderDlg.SelectedPath = Directory.GetCurrentDirectory();
folderDlg.Description = "选择脚本.sql文件存放路径";
if (folderDlg.ShowDialog() == DialogResult.OK)
{
tb_sqlpath.Text = folderDlg.SelectedPath;
NavChina.Common.APPConfig.GetAPPConfig().SetConfigValue("SqlFilePath", tb_sqlpath.Text);
}
////
2、文件选择
string fpth = "";
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "请选择走向文件";
openFileDialog.Filter = "文本文件|*.sql";
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
fpth = openFileDialog.FileName;
tb_sqlpath.Text = fpth;
//NavChina.Common.APPConfig.GetAPPConfig().SetConfigValue("SqlFilePath", fpth);
}
2016.5.9 文件选择和文件夹选择对话框