How to load mht from stream/string into a WebBrowser control?

前端 未结 3 1204
太阳男子
太阳男子 2020-12-19 20:46

The WebBrowser control loads properly any mht file if I use the Navigate method, but when I use the DocumentText or DocumentStre

相关标签:
3条回答
  • 2020-12-19 20:51

    I remember I was facing the same issue a few years ago and although I searched for a solution then I did not find any. In the end, I went for the temp-file approach. I wish you good luck, and if there's an answer I would like to know too.

    0 讨论(0)
  • 2020-12-19 20:58
    var uri = new Uri(String.Format("file:///{0}", Path.GetFullPath(source)));
    wbMain.Navigate(uri);
    

    where source - path to your .mht file

    0 讨论(0)
  • 2020-12-19 21:13

    in vb.net we've used

    Response.ContentType = "message/rfc822" 
    Dim ByteDocBlob() As Byte = cwWebUtil.ConvertLocalFileToByteArray(FilePath, True)
    Dim HTMLText As String = System.Text.Encoding.UTF8.GetString(ByteDocBlob)
    Response.Write(HTMLText)
    Response.End()
    

    Problem is only IE seems to accept it.

    0 讨论(0)
提交回复
热议问题