简体   繁体   中英

Save file path on show dialog

I want to save path on text box after Directory 1: whenever I try to close the application and open again the path is not there.I want it to show every time I open the application.

在此处输入图片说明

Private Sub btnRootBrowse1_Click(sender As System.Object, e As System.EventArgs) Handles btnBrowse1.Click
        RootFolderBrowserDialog.ShowDialog()
        txtPath1.Text = RootFolderBrowserDialog.SelectedPath
    End Sub

You need save your data (in this case txtPath1.Text) to Hard-Drive (File or DataBase) and reload it in the next execution.

It can be easy when you use Application-Setting :

  1. In the Solution Explorer, Double-Click "My Project"
  2. in left pane click "Setting"
  3. in the table, Fill in the fields as needed, example for you case: Name: DirectoryLocation Type: String Scope: User Value: Empty.
  4. Sample Code Using:

     Public Sub New() InitializeComponent() 'load from the hard-disk txtPath1.Text = My.Settings.DirectoryLocation End Sub Private Sub btnRootBrowse1_Click(sender As System.Object, e As System.EventArgs) Handles btnBrowse1.Click RootFolderBrowserDialog.ShowDialog() txtPath1.Text = RootFolderBrowserDialog.SelectedPath 'save to hard-disk My.Settings.DirectoryLocation = txtPath1.Text My.Settings.Save() End Sub 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM