System.Windows.Forms.RichTextBox.SaveFile Method

Saves the contents of the System.Windows.Forms.RichTextBox to a specific type of file.

Syntax

public void SaveFile (string path, RichTextBoxStreamType fileType)

Parameters

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

Remarks

The RichTextBox.SaveFile(string) method enables you to save the entire contents of the control to an RTF file that can be used by other programs such as Microsoft Word and Windows WordPad. If the file name that is passed to the path parameter already exists at the specified directory, the file will be overwritten without notice. You can use the RichTextBox.LoadFile(string) method to load the contents of a file into the System.Windows.Forms.RichTextBox.

This version of the RichTextBox.SaveFile(string) method enables you to specify a file type to save the contents of the control to. You can use this feature to ensure that the file is saved in the proper format based on the contents of the control. For example, if your document has no differences in font style or coloring, you can save the file as an ASCII text file by setting the fileType parameter to RichTextBoxStreamType.PlainText.

Requirements

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