user3188039
user3188039

Reputation: 49

Local html url in webbrowser control (visual basic)

I'm a beginner in VB, I'm trying to display html page in the webbrowser control. when I copy the full path of the html file, and put in the url properties of the webbrowser control, everything works. However, when I build the exe file and run it in different computer, the html page can not be displayed. I know this has to do with the html file path, I'm trying to find a way to display html page using webbrowser control in any computer.

any help will be great guys.

Upvotes: 1

Views: 6584

Answers (2)

AJDev
AJDev

Reputation: 1397

This is a little late, but better late then never! Sorry I did not find this sooner! Anyway, instead of adding the file url in the URL property of WebBrowser1, here is what you need to do:

  1. In Form1_Load add the following code:

    Dim appPath As String appPath = Application.StartupPath WebBrowser1.Navigate(appPath & "/html-file-name-here.html")

  2. Change the "html-file-name-here.html" to what your HTML file name is.
  3. Then when you compile your app, just put your html file in the folder where the app is launching from .

Upvotes: 0

Lukas2
Lukas2

Reputation: 320

Try:

WebBrowser1.Navigate(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) & "\info.html")

remember to add

Imports System.IO

Upvotes: 1

Related Questions