标签:
把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();
}
标签:
原文地址:http://www.cnblogs.com/lsgsanxiao/p/4748395.html