对于C#选择文件夹,代码
//弹出选择路径对话框
FolderBrowserDialog dialog = new FolderBrowserDialog();
//对话框的名字
dialog.Description = "Please choose the path ";
string foldPath = "";
//点击对话框的确定之后执行
if (dialog.ShowDialog() == DialogResult.OK)
{
foldPath = dialog.SelectedPath;
//MessageBox.Show("已选择文件夹:" + foldPath, "选择文件夹提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
textBox1.Text = foldPath;
string tem = textBox2.Text;
Gloable.excel_path = foldPath + "\\"+tem+".xlsx";
textBox1.Text = Gloable.excel_path;
C#选择文件
//弹出对话框
SaveFileDialog saveDlg = new SaveFileDialog();
//对话框提示,选择的类型
saveDlg.Filter = "文本文件|*.xlsx";
Gloable.excel_path = saveDlg.FileName;
if (saveDlg.ShowDialog() == DialogResult.OK)
{ }
textBox1.Text = Gloable.excel_path;