// Factory Methods public static FolderBrowserDialogEx PrinterBrowser() { FolderBrowserDialogEx x = new FolderBrowserDialogEx(); // avoid MBRO comppiler warning when passing _rootFolderLocation as a ref: x.BecomePrinterBrowser(); return(x); }
/// <summary> /// 选择提取文件保存路径 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCSRetvedFileSavePath_Click(object sender, EventArgs e) { FolderBrowserDialogEx folderDialogEx = new FolderBrowserDialogEx(); folderDialogEx.ShowNewFolderButton = false; folderDialogEx.Description = "请选择提取文件保存路径"; folderDialogEx.RootFolder = Environment.SpecialFolder.MyComputer;//打开我的电脑 if (folderDialogEx.ShowDialog() == DialogResult.OK) { string foldPath = folderDialogEx.SelectedPath; tbRetrievedFileSavePath.Text = foldPath; } }
/// <summary> ///获取号单路径 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Choose_Click(object sender, EventArgs e) { if (showFileDialog) //展示文件选择器 { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "任意文件(*.*)|*.txt"; dialog.Multiselect = false; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { HDFilePaths = null; tbHDFilePath.Text = string.Empty; HDFilePaths = new string[] { dialog.FileName }; tbHDFilePath.Text = dialog.FileName; } } else //文件夹模式 { FolderBrowserDialogEx folderDialogEx = new FolderBrowserDialogEx(); folderDialogEx.ShowNewFolderButton = false; folderDialogEx.Description = "请选择文件路径"; folderDialogEx.RootFolder = Environment.SpecialFolder.MyComputer;//打开我的电脑 if (folderDialogEx.ShowDialog() == DialogResult.OK) { string foldPath = folderDialogEx.SelectedPath; tbHDFilePath.Text = foldPath; HDFilePaths = new string[] { foldPath }; } } }