OpenFileDialog dialog = new OpenFileDialog(); if (dialog .ShowDialog() == DialogResult.OK) { this.txtboxPath.SelectedText = dialog.FileName; } //如果只显示文件名 OpenFileDialog dialog = new OpenFileDialog(); if (dialog .ShowDialog() == DialogResult.OK) { this.txtboxPath.SelectedText = d...
使用 OpenFileDialog ofd=newOpenFileDialog{Title="请选择文件",//对话框标题栏中显示的名称Filter="所有文件 (*.*)|*.*|文本文件 (*.txt)|*.txt",//指定对话框中显示的文件筛选器:InitialDirectory=Environment.GetFolderPath(Environment.SpecialFolder.Desktop),// 设置对话框的初始目录//Multiselect = true,//...
OpenFileDialog dialog = new OpenFileDialog(); //dialog.Multiselect = true;//该值确定是否可以选择多个文件 // dialog.Title = "请选择文件"; //dialog.Filter = "所有文件(*.*)|*.*"; //dialog.InitialDirectory = @"E:\"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ...
在Button1的Click事件里,添加下面的代码 OpenFileDialog dialog = new OpenFileDialog();dialog.ShowDialog();if (!string.IsNullOrEmpty(dialog.FileName)){ button2.Text = dialog.FileName;}
openfiler volumes模块 openfiledialog, Windows窗体的OpenFileDialog(打开文件对话框)组件是一个预先配置的对话框。它与 Windows操作系统的“打开文件”对话框相同。该控件是从CommonDialog类继承的。在基于Windows的应用程序中,可该组件
OpenFileDialog ofd = new OpenFileDialog();ofd.Title = "请选择图片"; 2)Filter: 用来获取或设置当前文件名筛选器字符串,不同筛选选项的字符串由垂直线条隔开. openDlg.Filter = "文本文件|*.txt" ; 例: private void btnSelectDataFile_Click(object sender, EventArgs e)使用一个选择按钮 ...
参考案例:WPF-Samples/Windows/CommonDialog at main · microsoft/WPF-Samples (github.com) 以下为历史遗留,仅供参考 原因 通过网络查找发现,很多人使用下面的语句判断文件获取是否成功。 if(openFileDialog.ShowDialog()==DialogResult.OK) 但是很快发现这个DialogResult下面没有OK的字段 ...
(new OpenFileDialogForm()); } private Button selectButton; private OpenFileDialog openFileDialog1; private TextBox textBox1; public OpenFileDialogForm() { openFileDialog1 = new OpenFileDialog(); selectButton = new Button { Size = new Size(100, 20), Location = new Point(15, 1...
这个可能是原来你拖入了一个这样的OpenFileDialog的控件,后台使用过这个控件,而页面上的控件,可能被你无意删除了吧,所以在运行的时候,就会报出这个错误(你的代码中有这个变量,但是没有声明)可以如下:using System.Windows.Forms;OpenFileDialog openFileDialogl = new OpenFileDialog();...
二、打开文件夹对话框( FolderBrowserDialog) FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择文件路径"; if (dialog.ShowDialog() == DialogResult.OK) { savePath = dialog.SelectedPath; textBox2.Text = savePath; } ...