C # Pop-up when saving files select the folder you want to save class code with the new folder effect

Source: Internet
Author: User
Tags empty

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




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.