如果是本地磁盘上的网页,可以考虑利用操作系统的文件关联自动调用操作系统默认浏览器:

System.Diagnostics.Process.Start("explorer.exe", "file:///" + htmlFilePath); //不能用destUri.AbsoluteUri,因为会进行URL转码导致找不到文件;

//如果不想调用外部浏览器,而是想在WPF程序本身预览本地磁盘上的某个网页,可以这样:
//先在窗口上放置一个Frame,起个名字叫previewFrame,然后
var destUri = new Uri("file:///" + htmlFilePath);
previewFrame.Source = destUri;
previewFrame.Refresh();

//file:///也是个协议的标志,一般网页改成http://呀、https://呀、ftp://呀啥的

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2021-12-26
  • 2021-11-29
  • 2021-12-31
猜你喜欢
  • 2022-12-23
  • 2021-12-03
  • 2021-12-06
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
相关资源
相似解决方案