如何在WP7的WebBrowser控件中讀取現有的html文件?如何在WP7的WebBrowser控件中讀取現有的html文件?
我曾嘗試:
流stream = Assembly.GetExecutingAssembly()GetManifestResourceStream( 「abc.htm」); StreamReader reader = new StreamReader(stream); string html = reader.ReadToEnd(); Browser.NavigateToString(html);
Browser.Navigate(new Uri(「abc.htm」,UriKind.Relative));
var rs = Application.GetResourceStream(new Uri(「abc.htm」,UriKind.Relative)); StreamReader sr = new StreamReader(rs.Stream); string html = sr.ReadToEnd(); Browser.NavigateToString(html);
所有這三個不工作。方法1和3給出NullReferenceException,因爲流返回null,基本上它不讀取我的html文件。
這裏有什麼問題?我該如何解決它?
對不起 - 我在哪裏檢查? – Sri
選擇HTML文件並查看其在Visual Studio中的屬性(通常位於VS的右下角)。有一個部分說'生成行動'。將其設置爲「內容」。 – keyboardP
謝謝!是的,我看到設置爲「內容」。仍然沒有工作:( – Sri