System.Windows.Forms.RichTextBox.LoadFile Method

Loads a specific type of file into the System.Windows.Forms.RichTextBox control.

Syntax

public void LoadFile (string path, RichTextBoxStreamType fileType)

Parameters

path
The name and location of the file to load into the control.
fileType
One of the System.Windows.Forms.RichTextBoxStreamType values.

Remarks

When loading a file with the RichTextBox.LoadFile(string) method, the contents of the file being loaded replace 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 previously created text or rich text format (RTF) document into the control for manipulation. If you want to save the file, you can use the RichTextBox.SaveFile(string) method.

You can use this version of the RichTextBox.LoadFile(string) method to specify the file type of the file being loaded. This feature enables you to load files other than 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