In the example below, the path set for the location of the rich-text file is the My Documents folder. This location is used because you can assume that most computers running the Windows operating system will include this folder. Choosing this location also allows users with minimal system access levels to safely run the application. The example below assumes a form with a RichTextBox control already added.
Public Sub SaveFile()
' You should replace the bold file name in the
' sample below with a file name of your own choosing.
RichTextBox1.SaveFile(System.Environment.GetFolderPath _
(System.Environment.SpecialFolder.Personal) _
& "\Testdoc.rtf", _
RichTextBoxStreamType.RichNoOleObjs)
End Sub
public void SaveFile()
{
// You should replace the bold file name in the
// sample below with a file name of your own choosing.
// Note the escape character used (@) when specifying the path.
richTextBox1.SaveFile(System.Environment.GetFolderPath
(System.Environment.SpecialFolder.Personal)
+ @"\Testdoc.rtf",
RichTextBoxStreamType.RichNoOleObjs);
}
public void SaveFile()
{
// You should replace the bold file name in the
// sample below with a file name of your own choosing.
richTextBox1.SaveFile(System.Environment.GetFolderPath
(System.Environment.SpecialFolder.Personal)
+ "\\Testdoc.rtf",
RichTextBoxStreamType.RichNoOleObjs);
}
public:
void SaveFile()
{
// You should replace the bold file name in the
// sample below with a file name of your own choosing.
richTextBox1->SaveFile(String::Concat
(System::Environment::GetFolderPath
(System::Environment::SpecialFolder::Personal),
"\\Testdoc.rtf"), RichTextBoxStreamType::RichNoOleObjs);
}