usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;namespacetestfolderbrowserdialog{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Private voidBtnfile_click (Objectsender, EventArgs e) {OpenFileDialog FileDialog=NewOpenFileDialog (); Filedialog.multiselect=true; Filedialog.title="Please select a file"; Filedialog.filter="All Files (*. *) |*.*"; if(Filedialog.showdialog () = =DialogResult.OK) {stringfile=Filedialog.filename; MessageBox.Show ("file selected:"+ File,"Select File Hints", messageboxbuttons.ok,messageboxicon.information); } } Private voidBtnpath_click (Objectsender, EventArgs e) {FolderBrowserDialog Dialog=NewFolderBrowserDialog (); Dialog. Description="Please select a file path"; if(dialog. ShowDialog () = =DialogResult.OK) {stringFoldpath =dialog. SelectedPath; MessageBox.Show ("folder selected:"+ Foldpath,"Select folder Hints", MessageBoxButtons.OK, messageboxicon.information); } } Private voidBtnopen_click (Objectsender, EventArgs e) {System.Diagnostics.Process.Start ("Explorer.exe","C:\\Windows"); } }}
Use C # to select folders, open folders, select files