我有一个将使用目录结构填充的文本框(例如,C:\Program Files\Visual Basic)。我正在尝试textbox.text
在另一个变量中使用该对象,但是当路径包含空格时,信息将被切断。
这是使用路径填充文本框的违规代码:
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles b_Script.Click
Dim BrowseFolder As New FolderBrowserDialog
BrowseFolder.ShowDialog()
tbScript.Text = BrowseFolder.SelectedPath
End Sub
请注意,它用于FolderBrowserDialog
填充文本框,这部分工作正常。我有另一个按钮单击,然后textbox.text
在我在其他地方定义的函数中使用特定文件名:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Path As String
Path = tbScript.Text & "\Client_Perfmon.ps1"
RunScript(Path)
End Sub
它永远无法解析文件名,例外是:
Exception:Caught: "The term 'C:\Users\seanlon\Desktop\Performance\Powershell' is not
recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try
again." (System.Management.Automation.CommandNotFoundException)
A System.Management.Automation.CommandNotFoundException was caught: "The term
'C:\Users\seanlon\Desktop\Performance\Powershell' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again."