0

How I can get URL of embedded resource(.html) in my app which I can use like a value of WebControl.Source? Or what better way to open embedded resources?

konstantin_doncov
  • 2,725
  • 4
  • 40
  • 100

1 Answers1

1

Embedded Resources do not have an URL instead the can be referenced with their namespace. Read about how to use embedded Resources:

http://www.codeproject.com/Articles/3089/Understanding-Embedded-Resources-in-Visual-Studio

There are also multiple questions and answers for this on stackoverflow:

How to read embedded resource text file

Community
  • 1
  • 1
Sjoerd222888
  • 3,228
  • 3
  • 31
  • 64
  • Yes, I understood this, but I found only how to use stream for load file in string and after that use loadHTML(). Is this the best and only solution? – konstantin_doncov Feb 16 '15 at 08:41
  • You can use the ResouceInterceptor and intercept the call to www.yourapp.com/index.html (in this case Source=www.yourapp.com/index.html) and then inject your html. You can also set the html directly with the html property I think. But the first one should be more efficient. – Sjoerd222888 Feb 16 '15 at 08:47
  • But how I can get access to the embedded resource? Just type "webControl.Source=www.yourapp.com/index.html"? – konstantin_doncov Feb 16 '15 at 08:51
  • It has to be an URI, something like: `webView.Source = new Uri("www.yourapp.com/index.html");` And then you need to intercept the call in the ResourceInterceptor: `public virtual ResourceResponse OnRequest(ResourceRequest request){ if(request.Url == new Uri("www.yourapp.com/index.html")){ /*load the embedded resource and inject it*/}}` – Sjoerd222888 Feb 16 '15 at 09:05
  • Yes, but I am said you about the part of "/*load the embedded resource and inject it*/": "Yes, I understood this, but I found only how to use stream for load file in string and after that use loadHTML(). Is this the best and only solution?" – konstantin_doncov Feb 16 '15 at 10:51
  • ??? I cannot follow you. You can use Source together with ResourceInterceptor for index.html, or you can use loadHTML(). If you want to load further resources, you either inject them from the very beginning into the html you put there with loadHTML or you use the ResourceInterceptor. So there are at least two possible solution. What is your question? – Sjoerd222888 Feb 16 '15 at 11:13
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/71013/discussion-between-sjoerd2228888-and-user2656632). – Sjoerd222888 Feb 16 '15 at 11:58