WebBrowser.DocumentStream 屬性

定義

取得或設定資料流,其中包含在 WebBrowser 控制項中顯示的網頁內容。

public:
 property System::IO::Stream ^ DocumentStream { System::IO::Stream ^ get(); void set(System::IO::Stream ^ value); };
[System.ComponentModel.Browsable(false)]
public System.IO.Stream DocumentStream { get; set; }
[System.ComponentModel.Browsable(false)]
public System.IO.Stream? DocumentStream { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.DocumentStream : System.IO.Stream with get, set
Public Property DocumentStream As Stream

屬性值

Stream,包含目前網頁的內容;如果未載入任何網頁,則為 null。 預設為 null

屬性

例外狀況

這個 WebBrowser 執行個體已不再有效。

無法從基礎 ActiveX IWebBrowser2 控制項中擷取 WebBrowser 介面實作的參考。

備註

使用這個屬性,從 物件將網頁 WebBrowser 載入控制項 Stream 。 例如,您可以使用這個屬性,從資料庫或資源檔載入網頁。 當您設定此屬性時, WebBrowser 控制項會在載入指定的文字之前自動巡覽至 about:blank URL。 這表示 Navigating 當您設定此屬性時,就會發生 、 NavigatedDocumentCompleted 事件,而且 屬性的值 Url 不再有意義。

注意

這個屬性包含目前檔的內容,即使已要求另一份檔也一樣。 如果您設定這個屬性的值,然後立即再次擷取它,如果 WebBrowser 控制項沒有時間載入新內容,擷取的值可能會與設定的值不同。 您可以在事件處理常式中 DocumentCompleted 擷取新值。

若要以字串的形式存取網頁的內容,請使用 DocumentText 屬性。 您也可以透過 屬性,使用 HTML 檔案物件模型 (DOM) Document 來存取頁面內容。

適用於

另請參閱