把MHT文件存成临时文件,用WEBBROWSER的Navigate方法打开,代码如下:

//从程序集中读取资源文件

Assembly asmm = Assembly.GetCallingAssembly();

Assembly asm = Assembly.ReflectionOnlyLoadFrom(AddInfo.HTMLAssembly);
Stream str=asm.GetManifestResourceStream(AddInfo.HTMLNavigationFile);

if (str == null)
return false;

//保存成临时文件

string vFilePath=AppDomain.CurrentDomain.BaseDirectory + "Temp";
string vFileName =vFilePath + "\\index.mht";//我资源文件里面的MHT文件

if (Directory.Exists(vFilePath) == false)
Directory.CreateDirectory(vFilePath);

if (File.Exists(vFileName))
File.Delete(vFileName);

StreamReader sr = new StreamReader(str);
StreamWriter sw = new StreamWriter(vFileName);

sw.Write(sr.ReadToEnd());
sw.Flush();
sw.Close();
sr.Close();

//webbrowser加载

wbNavigation.Navigate("file://"+vFileName);
while (wbNavigation.ReadyState != WebBrowserReadyState.Complete)
{
     Application.DoEvents();
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-09-29
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
猜你喜欢
  • 2022-02-10
  • 2022-03-05
  • 2021-12-12
  • 2022-12-23
  • 2021-04-23
  • 2022-12-23
相关资源
相似解决方案