Animated Gif not displaying in webBrowser control

2.3k views Asked by At

I am trying to put an animated gif on my smart device.

I am trying to do this using a webbrowser control. then on the form load i use the following code :

String imgPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()) + "\\PW.gif";

StringBuilder sb = new StringBuilder();
sb.Append("<html><body>");
sb.Append("<img src = \"" + imgPath + "\">");
sb.Append("</body></html>");

webBrowser1.DocumentText = sb.ToString();

but i get a red cross instead of the image. I have taken a look at the value of the string builder it is :

<html><body><img src = "\Program Files\FrontendTest\PW.gif"></body></html>

When i save this as a html file and run it on the device it works perfect.

any ideas as to why it wouldnt work in the webbrowser control ??

Thanks John

1

There are 1 answers

1
hemisphire On

Because it's a pain in the you-know-what. Unfortunately I ran into the same problem today. Try this instead (I have no idea why this is the case):

String imgPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase.ToString()) + "\\PW.gif"; 

StringBuilder sb = new StringBuilder();
sb.Append("<html><body>");
sb.Append("<img src = \"file:" + imgPath + "\">");
sb.Append("</body></html>");

webBrowser1.DocumentText = sb.ToString();