我正在尝试从VB.NET应用程序中运行目标相对路径。我确保使用反斜杠(而不是正斜杠),并运行Process,将工作目录设置为正确的源路径;尝试运行时仍然出现The system cannot find the file specified
错误。
例如,我有(伪代码):
txtSource.text path = "C:\Windows\System32"
txtResult.text path = "..\notepad.exe"
到目前为止,这是Sub:
Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
Try
' Create the process object
Dim pRun As New Process()
' Set it to run from the Source folder (Working Directory)
With pRun.StartInfo
.UseShellExecute = False
.WorkingDirectory = IO.Path.GetDirectoryName(txtSource.Text.Trim)
.FileName = txtResult.Text.Trim
End With
pRun.Start()
' Wait for it to finish
pRun.WaitForExit()
Catch ex As Exception
Debug.Print(ex.Message)
End Try
End Sub