How to load HTML/JavaScript from embedded resource into winform web browser

前端 未结 2 1870
暗喜
暗喜 2020-12-31 20:58

I want to have some HTML files with JavaScript loaded into the web browser control in a winforms (v2.0) application. During execution, I won\'t have internet access, so Java

2条回答
  •  孤城傲影
    2020-12-31 21:11

    Here's the file structure.

    I had success by doing this:

    Set the properties of the html files in my solution like this:

    Build Action -> Content
    Copy to Output Directory -> Copy always
    

    Configure my webBrowser object properties like this:

    var myAssembly = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
    var path = myAssembly.Substring(0, myAssembly.Length - "MyLib.DLL".Length) + "WebViews/prototype/index.html";
    webBrowser.Url = new Uri(path);
    

提交回复
热议问题