Load .jpg in webbrowser control

Does anyone know how to load a .jpg file into a webbrowser, from a local file on the hard disk?

This doesn't work:

WebBrowser2.Navigate ("C:\image.jpg")

But, I can go to regular Internet Explorer and type "C:\image.jpg" in the address bar and it comes up fine.

hrolsonsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

svgmucCommented:
WebBrowser2.Navigate ("file://c|/image.jpg")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hrolsonsAuthor Commented:
Didn't work for me.

I'm going to shut down firewall & anti-virus to rule that out.
0
hrolsonsAuthor Commented:
Still not working.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Try:

    WebBrowser2.Navigate "file://C:\image.jpg"
0
hrolsonsAuthor Commented:
No luck:

Navigation to the webpage was canceled
0
svgmucCommented:
I've tried it myself and for me,

WebBrowser2.Navigate "file://C:/image.jpg"

worked. Little odd and non-conforming but hey, it's MS.
0
hrolsonsAuthor Commented:
Fortunately, it's not vital to my project(would be nice though), but I can't get it to work trying all of the conventions above.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
What if you try to load it this way?

        Dim html As String
        html = "<img src=" & Chr(34) & "file://localhost/C:/Users/Mike/Pictures/AmericanFlag.jpg" & Chr(34) & " align=" & Chr(34) & "center" & Chr(34) & "/>"
        WebBrowser1.DocumentText = html
0
hrolsonsAuthor Commented:
"Object doesn't support this property or method"
0
hrolsonsAuthor Commented:
Interesting, out of frustration, I moved the file from it's long path to C:\image.jpg and it worked.  So then I thought it might be a backslash,forward slash issue.  But it actually turned out to be the fact that my W: drive is a mapped drive to my web server.  Not sure why it doesn't like it, but that's a different subject all together.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
Sorry...I'm working in VB.Net...try this:
Dim html As String
html = "<img src=" & Chr(34) & "file://localhost/C:/Users/Mike/Pictures/AmericanFlag.jpg" & Chr(34) & " align=" & Chr(34) & "center" & Chr(34) & "/>"
WebBrowser1.Navigate "about:blank"
While (WebBrowser1.Document Is Nothing)
   DoEvents
Wend
With WebBrowser1.Document
   .Open
   .Write html
   .Close
End With

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.