试图创造一个魔兽世界"发射器。
它应该如何运作: 按"启动Authserver"你可以找到authserver.exe。然后保存位置,这样你就不必两次这样做了。 一旦按下,显然应该启动authserver.exe。
会发生什么: 按"启动Authserver"它会打开并立即关闭并显示错误: 错误,无法打开导致authserver.conf无法找到。
注意: Authserver.exe和authserver.conf位于同一个文件夹中,我可以手动启动它。
Mort昨天帮助我解决了类似的问题,我希望相同的VB代码可以工作,因为这看起来很明显。
Private filePath As String = String.Empty
Private Sub PlayButton_Click(sender As System.Object, e As System.EventArgs) Handles PlayButton.Click
Try
If filePath.Length = 0 Then
Dim diagResult As DialogResult = OpenFileDialog1.ShowDialog()
If diagResult = Windows.Forms.DialogResult.OK Then
filePath = OpenFileDialog1.FileName
If filePath.ToUpper.EndsWith("WOW.EXE") Then
Process.Start(filePath)
Else
MessageBox.Show("Wrong file selected!")
filePath = String.Empty
End If
End If
Else
Process.Start(filePath)
End If
Catch ex As Exception
MessageBox.Show(String.Concat("An error occurred in the play button click:", ex.Message))
End Try
End Sub
有人有个主意吗? 提前:谢谢。
答案 0 :(得分:0)
尝试这样的事情:
Private Sub PlayButton_Click(sender As System.Object, e As System.EventArgs) Handles PlayButton.Click
Try
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "World of Warcraft (WOW.EXE)|WOW.EXE"
Dim diagResult As DialogResult = OpenFileDialog1.ShowDialog
If diagResult = Windows.Forms.DialogResult.OK Then
Dim p As New Process
Dim fn As New System.IO.FileInfo(OpenFileDialog1.FileName)
p.StartInfo.WorkingDirectory = fn.DirectoryName
p.StartInfo.FileName = fn.Name
p.Start()
End If
Catch ex As Exception
MessageBox.Show(String.Concat("An error occurred in the play button click:", ex.Message))
End Try
End Sub