c# 选择文件或文件夹
void Button1_select_ffmpegClick(object sender, EventArgs e) { //选择文件 OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = true;//该值确定是否可以选择多个文件 dialog.Title = "请选择文件夹"; dialog.Filter = "所有文件(*.*)|*.*"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ffmpeg_address.Text = dialog.FileName;//把值保存到文本框 } }
void Button1_select_dirClick(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择文件路径"; dialog.SelectedPath = "E:\\新建文件夹";//默认文件夹 //dialog.RootFolder = Environment.SpecialFolder.Programs; if (dialog.ShowDialog() == DialogResult.OK) { textBox1_editdir.Text = dialog.SelectedPath;//把值保存到文本框 } }
上一篇: c# 从大图中截取一部分图片
下一篇: c# 调用外部程序对文件夹内文件进行处理