System.Windows.Forms.RichTextBox.LoadFile Method

Loads the contents of an existing data stream into the System.Windows.Forms.RichTextBox control.

Syntax

public void LoadFile (System.IO.Stream data, RichTextBoxStreamType fileType)

Parameters

data
A stream of data to load into the System.Windows.Forms.RichTextBox control.
fileType
One of the System.Windows.Forms.RichTextBoxStreamType values.

Remarks

You can use this version of the RichTextBox.LoadFile(string) method to load the System.Windows.Forms.RichTextBox with data from an existing stream of data. The data that is loaded into the control replaces the entire contents of the System.Windows.Forms.RichTextBox control. This will cause the values of the TextBoxBase.Text and RichTextBox.Rtf properties to change. You can use this method to load a file that has been previously opened into a data stream into the control for manipulation. If you want to save contents of the control back into the stream, you can use the RichTextBox.SaveFile(string) method that accepts a System.IO.Stream object as a parameter.

This version of the RichTextBox.LoadFile(string) method also enables you to specify the type of data that is being loaded into the control. This feature enables you to use data streams that contain data other than rich text format (RTF) documents into the control.

Note:

The RichTextBox.LoadFile(string) method will not open a file until a handle is created for the System.Windows.Forms.RichTextBox. Ensure that the control's handle is created before calling the RichTextBox.LoadFile(string) method.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0