2015-01-30 9 views
4

test.html이라는 파일을 얻었습니다.이 파일은 텍스트가 들어있는 기본 html 파일입니다. test.html은 C# 프로젝트의 리소스이며 html 파일을로드해야하는 webbrowser1이라는 웹 브라우저가 있습니다. C# : 내부 .html 파일 리소스를 웹 브라우저 컨트롤에로드하는 방법?

는 어떻게 내 웹 브라우저

나는이 시도에 test.html를로드 할 수 있지만 작동하지 않습니다

private void button1_Click(object sender, EventArgs e) 
{ 
    webBrowser1.DocumentStream = 
     Properties.Resources.ResourceManager.GetStream("test.html"); 
} 

모든 솔루션을하세요?

+0

[C#을 웹 브라우저에서로드 로컬 HTML 파일]의 중복 가능성 (HTTP 될 겁니다 /stackoverflow.com/questions/7194851/load-local-html-file-in-ac-sharp-webbrowser) – MethodMan

+0

이것을 확인 했습니까? http://stackoverflow.com/questions/7194851/load-local-html-file-in-ac-sharp-webbrowser – user1462616

+0

나는 그 모든 것을 점검했지만 그 중 나에게 작용하지 않는 작품은 ... 내 자원을 의미한다. 하드 디스크가 아닌 솔루션에 내장되어 있습니다! 그래서 그것은 그런 일을하지 않습니다. –

답변

8

"test.html"은 (는) 리소스에 유효한 이름이 아닙니다. 대신에 "test_html"을 사용해보십시오. 그럼 다음은 잘 작동합니다./:

private void button1_Click(object sender, EventArgs e) 
{ 
    string html = Properties.Resources.test_html; 
    webBrowser1.DocumentText = html; 
} 

HTML 파일이 그렇다면

<!DOCTYPE html> 
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta charset="utf-8" /> 
    <title></title> 
</head> 
<body> 
    This is some resource HTML 
</body> 
</html> 

당신은

enter image description here