'Edit RichTextBox programmatically without losing formatting

I have formatted text in the rtf file and I load it to my richTextBox. It works fine, but then I want to remove some text parts programmatically. If I do like that:

richTextBox.LoadFile("TextFile.rtf");
richTextBox.Text = richTextBox1.Text.Substring(fromPosition, length);

text formatting disappears. I've tried to work with richTextBox.Lines, but there is no delete or edit function. All I need is to delete parts of loaded text without losing its formatting. Is it possible?

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source