我想在目录1之后保存文本框上的路径:每当我尝试关闭应用程序并再次打开时,路径就不存在。我希望每次打开应用程序时都显示它。
Private Sub btnRootBrowse1_Click(sender As System.Object, e As System.EventArgs) Handles btnBrowse1.Click
RootFolderBrowserDialog.ShowDialog()
txtPath1.Text = RootFolderBrowserDialog.SelectedPath
End Sub
答案 0 :(得分:1)
您需要将数据(在本例中为txtPath1.Text)保存到硬盘驱动器(文件或数据库),并在下次执行时重新加载。
时可以很容易示例代码使用:
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