Dim dialog As New FolderBrowserDialog()
dialog.RootFolder = Environment.SpecialFolder.Desktop
Me.Label1.Text = dialog.SelectedPath = "C:\wamp\www"
dialog.Description = "Select Application Configeration Files Path"
' If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
' apppath = dialog.SelectedPath
' End If
My.Computer.FileSystem.WriteAllText(apppath & "\apppath.txt", apppath, False)
</i>
我只需要在代码中选择的路径。当在标签表单中查看它时,它只打印错误!!
答案 0 :(得分:2)
这一行
Me.Label1.Text = dialog.SelectedPath = "C:\wamp\www"
表示:
如果dialog.SelectedPath
等于"c:\wamp\www"
,则将Label1.Text设置为True,否则将其设置为false。
我想你想做的是
Dim dialog As New FolderBrowserDialog()
dialog.RootFolder = Environment.SpecialFolder.Desktop
dialog.SelectedPath = "C:\wamp\www"
dialog.Description = "Select Application Configeration Files Path"
If dialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
apppath = dialog.SelectedPath
Me.Label1.Text = apppath
My.Computer.FileSystem.WriteAllText(apppath & "\apppath.txt", apppath, False)
Else
MessageBox.Show("No folder selected")
End If