WebBrowser.DocumentStream WebBrowser.DocumentStream WebBrowser.DocumentStream WebBrowser.DocumentStream Property


取得或設定資料流,其中包含 WebBrowser 控制項中所顯示的 Web 網頁內容。Gets or sets a stream containing the contents of the Web page displayed in the WebBrowser control.

 property System::IO::Stream ^ DocumentStream { System::IO::Stream ^ get(); void set(System::IO::Stream ^ value); };
public System.IO.Stream DocumentStream { get; set; }
member this.DocumentStream : System.IO.Stream with get, set
Public Property DocumentStream As Stream


Stream 包含目前 Web 網頁的內容;如果未載入任何網頁,則為 nullA Stream containing the contents of the current Web page, or null if no page is loaded. 預設為 nullThe default is null.


這個 WebBrowser 執行個體已不再有效。This WebBrowser instance is no longer valid.

無法從基礎 ActiveX IWebBrowser2 控制項中擷取 WebBrowser 介面實作的參考。A reference to an implementation of the IWebBrowser2 interface could not be retrieved from the underlying ActiveX WebBrowser control.


使用這個屬性來載入到網頁WebBrowser控制項從Stream物件。Use this property to load a Web page into the WebBrowser control from a Stream object. 您可以從資料庫或資源檔載入網頁,比方說,使用這個屬性。You can use this property, for example, to load Web pages from a database or resource file. 當您設定此屬性,WebBrowser控制項自動巡覽至相關: 空白 URL,然後再載入指定的文字。When you set this property, the WebBrowser control automatically navigates to the about:blank URL before loading the specified text. 這表示NavigatingNavigated,並DocumentCompleted當您設定此屬性,以及的值時,就會發生事件Url屬性不再有意義。This means that the Navigating, Navigated, and DocumentCompleted events occur when you set this property, and the value of the Url property is no longer meaningful.


此屬性包含目前的文件的內容,即使已經要求另一個文件。This property contains the contents of the current document, even if another document has been requested. 如果您設定這個屬性的值,並再次立即擷取它,擷取的值可能會不同的值設定如果WebBrowser控制項還沒有時間來載入新的內容。If you set the value of this property and then immediately retrieve it again, the value retrieved may be different than the value set if the WebBrowser control has not had time to load the new content. 您可以擷取中的新值DocumentCompleted事件處理常式。You can retrieve the new value in a DocumentCompleted event handler.

若要存取的字串形式的網頁內容,請使用DocumentText屬性。To access the contents of a Web page as a string, use the DocumentText property. 您也可以透過存取使用 HTML 文件物件模型 (DOM) 的頁面內容Document屬性。You can also access the page contents using the HTML document object model (DOM) through the Document property.


使用此控制項的立即呼叫端。for immediate callers to use this control. 要求值: LinkDemand;[NIB:具名使用權限集合](https://msdn.microsoft.com/library/08250d67-c99d-4ab0-8d2b-b0e12019f6e3): FullTrustDemand value: LinkDemand; [NIB: Named Permission Sets](https://msdn.microsoft.com/library/08250d67-c99d-4ab0-8d2b-b0e12019f6e3): FullTrust.