我在询问用户文件的位置后,尝试使用VB.NET启动.jar文件。一切似乎都有效,但当我确认文件对话框时,我得到一个错误,基本上说无法找到该文件。这是我的代码:
Class MainWindow
Dim ServerDir As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim fd As OpenFileDialog = New OpenFileDialog()
fd.Title = "Select Server JAR"
fd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
fd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
fd.FilterIndex = 0
If fd.ShowDialog = Windows.Forms.DialogResult.OK Then
ServerDir = fd.FileName
End If
Call LaunchServer()
End Sub
Private Sub LaunchServer()
Try
Process.Start("java -Xmx1024M -Xms1024M -jar" & ServerDir)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
有什么建议吗?