Windows Forms: How to read .rtf file in C#

How to read rich text format (*.rtf) file using RichTextBox in c#

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "ReadRtfFile" and then click OK

c# read rtf fileStep 2: Design your form as below

read rtf file in c#

Step 3: Add code to button click event handler as below

//Open file dialog, allows you to select a rtf file
private void btnOpen_Click(object sender, EventArgs e)
{
    using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "Rich Text Format|*.rtf", ValidateNames = true, Multiselect = false })
    {
        if (ofd.ShowDialog() == DialogResult.OK)
            richTextBox.LoadFile(ofd.FileName);
    }
}

VIDEO TUTORIALS