none
webview程序如何打开本地页面 RRS feed

  • 问题

  • webview程序如何打开本地页面?

    我的代码如下

    public MainPage()
            {
                this.InitializeComponent();
                String sURL = System.IO.Directory.GetCurrentDirectory() + "\\fruit\\index.html";
                webview1.Navigate(new Uri(sURL));
            }

    但是窗口是空白的。

    URL路径应该没错,在ie中能打开。

    2015年9月22日 11:06

全部回复

  • 你好,

    试试看下面的路径

    string curDir = Directory.GetCurrentDirectory();
    this.webBrowser1.Url = new Uri(String.Format("file:///{0}/my_html.html", curDir));


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年9月23日 11:33
  • 你好,

    试试看下面的路径

    string curDir = Directory.GetCurrentDirectory();
    this.webBrowser1.Url = new Uri(String.Format("file:///{0}/my_html.html", curDir));


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    string curDir = Directory.GetCurrentDirectory();
                string sFile = string.Format("file:///{0}//fruit//index.html", curDir);
                webview1.Navigate(new Uri(sFile));

    写成这样还是不行。

    sFile 的值在ie中能打开。

    我是win 10 vs2015开发的。

    2015年9月24日 12:38
  • NavigateToString(string/Uri);
    用于打开本地 HTML 文件。
    2015年9月24日 14:20