使用OpenFileDialog打开文件和使用FolderBrowserDialog选定文件夹

选定文件夹
string foldPath = ""; FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "请选择文件路径"; dialog.SelectedPath = ""; //dialog.RootFolder = Environment.SpecialFolder.Programs; if (dialog.ShowDialog() == DialogResult.OK) { foldPath = dialog.SelectedPath; } else { return; }

打开文件

		OpenFileDialog openFileDialog1 = new OpenFileDialog();
		string File_Name = "";
		openFileDialog1.Filter = "所有文件(*.*)|*.*";
		if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
		{
			File_Name = openFileDialog1.FileName;

		}
		else
		{
			return;
		}

`

上一篇:elementui中table和dialog中数据回显和校验清空的问题


下一篇:vue+el-dialog中使用codemirror 遇到的问题