2012-07-05 2 views
1

Windows Phone 7.1에서는 WebBrowser에서 로컬 파일을로드하려고 시도하지만 Im은 항상 예외 또는 빈 페이지를 가져옵니다. WebBrowser 컨트롤에서 로컬 파일로드

나는

Stream stream = Application.GetResourceStream(
        new Uri("./Html/par/index.html", 
        UriKind.Relative)).Stream; 
using (StreamReader reader = new StreamReader(stream)) 
{ 
    // Navigate to HTML document string 
    this.webBrowser.NavigateToString(reader.ReadToEnd()); 
} 

이 빈 페이지를 발사한다로했습니다.

필자는 index.html과 필요한 모든 파일 (css/js)을 Content 및 IsScriptEnable을 "true"로 설정했습니다.

이 문제를 해결하는 방법에 대해 알고 계신가요?

답변

2

경로가 잘못되었다고 생각합니다.

프로젝트에 /Html/par 디렉토리가 있습니까? 둘째로 index.html이 content로 설정되어 있습니까?

는이 자원과 내용 사이 undertand에 차이 도움이 될 http://phone7.wordpress.com/2010/08/08/loading-a-local-html-file-in-the-webbrowser-control/

도움이 될 수 있습니다

var rs = Application.GetResourceStream(new Uri("myFile.html", UriKind.Relative)); 
using(StreamReader sr = new StreamReader(rs.Stream)) 
{ 
    this.webBrowser.NavigateToString(sr.ReadToEnd()); 
} 

시도 http://invokeit.wordpress.com/2011/09/30/images-and-build-actio-settings-in-wp7/

이 링크하는 방법 파일 및 기타 링크 된 파일 http://transoceanic.blogspot.co.uk/2011/07/wp7-load-local-html-files-and-all.html을로드하는 사항

+0

StreamReader reader = 새 StreamReader (TitleContainer.OpenStream ("test.html")); webBrowser1.NavigateToString (reader.ReadToEnd()); 나는 이것도 사용했다. 문제는 경로가 아니지만 실제로는 지정된 HTML을로드하지만 로컬 스크립트/스타일 파일/이미지는로드하지 않습니다. 이러한 파일을 스트리밍하는 방법에 대한 아이디어가 있으십니까? – fran

+1

이 링크를 사용해보세요 http://transoceanic.blogspot.co.uk/2011/07/wp7-load-local-html-files-and-all.html –

+0

감사합니다! 매력처럼 작동하지만 부끄러운 줄 알았습니다. 로컬 파일을로드하려면이 작업을 수행해야합니다 ... 두 번째 방법이 있기를 바랍니다 ... 그러나 이것이 가장 좋은 대답입니다! 건배! – fran

관련 문제