RichTextBoxStreamType Enumeration
Assembly: System.Windows.Forms (in system.windows.forms.dll)
| Member name | Description | |
|---|---|---|
| PlainText | A plain text stream that includes spaces in places of Object Linking and Embedding (OLE) objects. | |
| RichNoOleObjs | A Rich Text Format (RTF) stream with spaces in place of OLE objects. This value is only valid for use with the SaveFile method of the RichTextBox control. | |
| RichText | A Rich Text Format (RTF) stream. | |
| TextTextOleObjs | A plain text stream with a textual representation of OLE objects. This value is only valid for use with the SaveFile method of the RichTextBox control. | |
| UnicodePlainText | A text stream that contains spaces in place of Object Linking and Embedding (OLE) objects. The text is encoded in Unicode. |
The following example saves the contents of the RichTextBox into an ASCII text file. The example uses the SaveFileDialog class to display a dialog to request the path and file name from the user. The code then saves the contents of the control to that file. The example uses this version of the SaveFile method to specify that the file be saved as an ASCII text file instead of the standard Rich Text Format. This example assumes that the code is placed in a Form class that has a RichTextBox control named richTextBox1.
public void SaveMyFile() { // Create a SaveFileDialog to request a path and file name to save to. SaveFileDialog saveFile1 = new SaveFileDialog(); // Initialize the SaveFileDialog to specify the RTF extension for the file. saveFile1.DefaultExt = "*.rtf"; saveFile1.Filter = "RTF Files|*.rtf"; // Determine if the user selected a file name from the saveFileDialog. if(saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK && saveFile1.FileName.Length > 0) { // Save the contents of the RichTextBox into the file. richTextBox1.SaveFile(saveFile1.FileName, RichTextBoxStreamType.PlainText); } }
public void SaveMyFile()
{
// Create a SaveFileDialog to request a path and file name to save to.
SaveFileDialog saveFile1 = new SaveFileDialog();
// Initialize the SaveFileDialog to specify the RTF extension for the
// file.
saveFile1.set_DefaultExt("*.rtf");
saveFile1.set_Filter("RTF Files|*.rtf");
// Determine if the user selected a file name from the saveFileDialog.
if (saveFile1.ShowDialog() ==
System.Windows.Forms.DialogResult.OK &&
saveFile1.get_FileName().length() > 0) {
// Save the contents of the RichTextBox into the file.
richTextBox1.SaveFile(
saveFile1.get_FileName(), RichTextBoxStreamType.PlainText);
}
} //SaveMyFile
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.