-
Mar 4th, 2018, 05:40 AM
#1
Thread Starter
Lively Member
WebBrowser control is not displaying local HTML files
Hi guys
I wasted a week so far reading and trying all the solutions I can find on the net only to find that they do no work.
I have a listbox that shows the filename of all files in a "show" folder. Clicking on a filename should display the HTML file in the webbrowser control.
Here is the code I'm using at the moment and the actual file location is "D:\The Penfound Project\family\show\1.html"
Code:
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
Dim SF, URLString As String
SF = ListBox1.SelectedItem.ToString
SF = myPath & SF
WebBrowser1.AllowNavigation = True
URLString = "file:///" & SF
URLString = URLString.Replace("\", "/") 'this does not work
'URLString = "https://penfound.org" 'this works
Me.WebBrowser1.Navigate(URLString)
WebBrowser1.Update()
End Sub
When I click on a filename the program locks up wit ha blank browser area.
Last edited by dday9; Mar 5th, 2018 at 04:18 PM.
-
Mar 4th, 2018, 10:23 AM
#2
Re: WebBrowser control is not displaying local HTML files
It's been a while, but I believe it should be file:// not file:///
And those should be the only forward slashes, the rest in the path should remain as back slashes.
-tg
-
Mar 5th, 2018, 10:44 AM
#3
Re: WebBrowser control is not displaying local HTML files
Originally Posted by techgnome
It's been a while, but I believe it should be file:// not file:///
And those should be the only forward slashes, the rest in the path should remain as back slashes.
-tg
At least using Chrome, opening a local HTML results in file:///C:/Users/FMS-VB/Documents/test.html in its address bar.
Originally Posted by Penfound
URLString = URLString.Replace("\", "/") 'this does not work
What is the value of URLString after this line?
-
Mar 5th, 2018, 12:02 PM
#4
Thread Starter
Lively Member
Re: WebBrowser control is not displaying local HTML files
Thanks for your input guys - unfortunately neither works.
Maybe MS will make one that does work in the next edition of VS
-
Mar 5th, 2018, 03:07 PM
#5
Re: WebBrowser control is not displaying local HTML files
Originally Posted by Penfound
Thanks for your input guys - unfortunately neither works.
Maybe MS will make one that does work in the next edition of VS
Define doesn't work. What error are you getting? Perhaps you should trap whatever exception you must be getting to lock up.
Using VS2013 on WIn 7, I can do
Code:
Try
Me.WebBrowser1.Navigate("file:///C:/Users/FMS-VB/Documents/test.html")
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
and it shows my test page. I'm thinking your URLString isn't exactly what you think it is or there is some kind of permissions issue or maybe something wrong with the HTML in the file.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|