例子:
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; }
标签:文件,false,示例,C#,Text,选择,OpenFileDialog,dialog From: https://www.cnblogs.com/Kirito-Asuna-Yoyi/p/17547112.html