How do I get only the content of the .rtf file?
How do I find where .rtf file's header stops and footer starts in C#?
I've read it with
using (var sr = new StreamReader(myRtfFilePath))
{
fullText = sr.ReadToEnd();
encoding = sr.CurrentEncoding;
}
and I can find the content I write like this
var startIndex = fullText.IndexOf("start");
but that means I have to manually add 'start' and 'end' to my .rtf file so that I can see where content starts and where it ends.
To extract just the content of an RTF file in C#, you can use the System.Windows.Forms.RichTextBox control, which has a built-in capability to handle RTF format. Here's an example of how you might do this:
Regarding your second question about finding where the RTF file's header stops and the footer starts.
If you've manually added markers like "start" and "end" in your RTF file, you can find the content between these markers using IndexOf as you've mentioned. Here's an example: