0

I'm embedding a web page in my program using this method:

WebBrowser1.DocumentText = "<b>hello</b> world <img src=""/images/amiga.png"" />"

so the html is in the program, but I would like to load the css and images from an outside place (such as ./themes/default/style.css).

So where do I put the files during development, and what do I makes the paths?

I want the html to be static but allow users to change the css.

edit: actually, since it's in the code, if there's something in vb that puts in the program location, that could work, like %programlocation% + "/themes/default/style.css"

and I'm also looking into using gecko instead of the ie rendering engine, so if anyone knows a good way to do it let me know

stackers
  • 2,701
  • 4
  • 34
  • 66

1 Answers1

3

So you're trying to do this purely from the filesystem, and with no web server? I'm not completely sure if this would work, but you could try doing:

WebBrowser1.DocumentText = "<head><link rel=""StyleSheet"" HREF=""file:///" & Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location).Replace("\\", "/") & "/themes/default/style.css"" TYPE=""text/css"" /></head><body><b>hello</b> world <img src=""/images/amiga.png"" /></body></html>"
Adam Plocher
  • 13,994
  • 6
  • 46
  • 79
  • What if they install it to a different location? edit: actually, since it's in the code, if there's something in vb that puts in the program location, that could work, like %programlocation% + "/themes/default/style.css" – stackers Sep 30 '12 at 01:19
  • I just updated my example to account for that. Note, I'm not a huge VB.NET dev (more C#) so if my syntax is bad, please forgive me :). EDIT: Btw, note that I'm replacing backslashes with forward slashes, because of the syntax. Newer versions of IE might not allow direct access to the filesystem for security reasons, though. The file:/// syntax is correct, but it could be a security issue that IE prevents. – Adam Plocher Sep 30 '12 at 01:26
  • did a little looking around, it actually looks like it can be done with just "Application.StartupPath()", will see if that works – stackers Sep 30 '12 at 01:33