-2

I'm trying to create a simple webbrowser that automatically opends a html file named "Index.html" found in the same folder the application is run.

This is the code:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate(@".\index.html")
    End Sub
End Class

It does not work, I always get an "Expression expected" error. What am I doing wrong?

user1885099
  • 130
  • 2
  • 6
  • 28
  • That's visual basic, not c#. – George Simms Aug 10 '15 at 19:42
  • remove `;` end of Navigate. – Mitat Koyuncu Aug 10 '15 at 19:43
  • removing the ; did not help, I get the same error. – user1885099 Aug 10 '15 at 19:45
  • google the error and see if you can fix the issue.. also you are not creating a simple web browser you are just opening up your default web browser with a path to a file name.. why doing you try changing the backslash to a forward slash and replace the `.` with the following http://stackoverflow.com/questions/7194851/load-local-html-file-in-a-c-sharp-webbrowser found here.. start using google or your other favorite internet search engine to find working examples – MethodMan Aug 10 '15 at 19:49

1 Answers1

0

The other post did not help, I found the answer my self.

This is the answer:

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Url = New Uri(String.Format("file:///{0}/index.html", CurDir))
    End Sub
End Class
user1885099
  • 130
  • 2
  • 6
  • 28