C# 选择文件选择设置类型示例
例子:
OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false; //该值确定是否可以选择多个文件 dialog.Title = "请选择文件"; dialog.Filter = "图像文件(*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp;*.jpge"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //设置图片路径 } OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false; //该值确定是否可以选择多个文件 dialog.Title = "请选择文件"; dialog.Filter = "文本文件(*.txt)|*.txt"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //Text_Path.Text = dialog.FileName; } OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false; //该值确定是否可以选择多个文件 dialog.Title = "请选择文件"; dialog.Filter = "所有文件(*.*)|*.*"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //Text_Path.Text = dialog.FileName; }