Add Reference System.Design.dll
Select the save path for the file
Dirbrowser olderbrowserdlg=new Dirbrowser ();
if (Folderbrowserdlg.showdialog () ==dialogresult.ok)
{
Txtfilepath.text = Folderbrowserdlg.selectedpath;
}
//
Using System.Windows.Forms.Design;
Using System.Windows.Forms;
Using System;
General selection file Save address with pop-up dialog box to select
public class Directoryselect:foldernameeditor
{
Private FolderBrowser fb = new FolderBrowser ();
private string fdescription = "Choose Directory";
private string freturnpath = String.Empty;
public string Description
{
set {fdescription = value;}
get {return fdescription;}
}
public string Returnpath
{
get {return freturnpath;}
}
Public Directoryselect ()
{
}
Private DialogResult RunDialog ()
{
Fb. Description = this. Description;
Fb. Startlocation = Folderbrowserfolder.mycomputer;
Fb. Style = folderbrowserstyles.restricttosubfolders;
//| Folderbrowserstyles.restricttodomain;
Return FB. ShowDialog ();
}
Public DialogResult ShowDialog ()
{
DialogResult dres = Dialogresult.none;
Dres = RunDialog ();
if (Dres = = DialogResult.OK)
This.freturnpath = fb. DirectoryPath;
Else
This.freturnpath = String.Empty;
return dres;
}
}
General selection file Save address with pop-up dialog box to select
Call
Dirbrowser mydirbrowser=new Dirbrowser ();
if (Mydirbrowser.showdialog ()!=dialogresult.cancel)
MessageBox.Show (Mydirbrowser.returnpath);
public class Dirbrowser:foldernameeditor
{
FolderBrowser fb = new FolderBrowser ();
public string Description
{
set {_description = value; }
get {return _description; }
}
public string Returnpath
{
get {return _returnpath; }
}
Public Dirbrowser () {}
Public DialogResult ShowDialog ()
{
Fb. Description = _description;
Fb. Startlocation = Folderbrowserfolder.mycomputer;
DialogResult r = fb. ShowDialog ();
if (r = = DialogResult.OK)
_returnpath = fb. DirectoryPath;
Else
_returnpath = String.Empty;
return R;
}
private string _description = "Choose Directory";
private string _returnpath = String.Empty;
private string _description = "Please select folder";
private string _returnpath = String.Empty;
}