私はVB.NETアプリケーション内から目的の相対パスを実行しようとしています。私はバックスラッシュ(スラッシュではなく)を使用して、作業ディレクトリを正しいソースパスに設定してプロセスを実行しました。それを実行しようとするとまだThe system cannot find the file specified
というエラーが表示されます。Windowsで相対パスを実行しますか?
例えば、私は(擬似コード)を有する:
txtSource.text path = "C:\Windows\System32"
txtResult.text path = "..\notepad.exe"
ここでこれまでサブだ:
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
2つのドット( '..')は、現在のディレクトリレベルよりも1つ上のディレクトリを意味します。 1つのドット( '.')は現在のディレクトリを意味します。 – TnTinMn
この例では、C:\ Windows \ notepad.exeは、C:\ Windows \ System32より1つ上位のディレクトリです。 –