Creating rtf file from rtf text in c#

 
The following code sample saves rtf text to an RTF file.this example use SaveFile method of richtextbox control class without adding any RichTextBox control on the windows form.

you need to add reference of ‘System.Windows.Forms’ before using this code sample.

void SaveRtfFile(string rtfText, string Rtfpath)
   {
       System.Windows.Forms.RichTextBox rtfBox = new System.Windows.Forms.RichTextBox();
       rtfBox.Rtf = rtfText;
       rtfBox.SaveFile(Rtfpath);
    }

The code saves the rtf text to rtf file according to given path. If the file already exists, it is automatically overwritten without notice