1

在询问用户他们的文件在哪里之后,我正在尝试使用 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

有什么建议么?

4

0 回答 0