Search code examples
vb.netkmlgoogle-earth

KML not opening in Google Earth through VB.net


I am writing an app for opening KML file using Google earth installed on my PC. But my code is not finding the file.

This is my code:

Public Class openkml
    Sub kmlopener()
        Dim ge As String
        Dim gf As String
        ge = "C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe"
        gf = "C:\Program Files (x86)\Google\Google Earth\client\abc.kml"


        Process.Start(ge, gf)
    End Sub

End Class

Also, just typing this in command line ( DOS ) opens file :

"C:\Program Files (x86)\Google\Google Earth\client\googleearth.exe" abc.kml

File is present in the mentioned location. Google earth opens, but does not finds the file. I have put the kml file in different directory also, like D directory, but shows same error. Below is the screenshot of the error.

enter image description here


Solution

  • The problem is the spaces in the path. You can add quotes to the parameter and it should work:

    gf = """C:\Program Files (x86)\Google\Google Earth\client\abc.kml"""