其他分享
首页 > 其他分享> > 使用OpenFileDialog打开文件和使用FolderBrowserDialog选定文件夹

使用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;
		}

`

标签:文件,FolderBrowserDialog,DialogResult,openFileDialog1,文件夹,OpenFileDialog,dialog
来源: https://www.cnblogs.com/dengzhekaihua/p/15524270.html