C# read rtf file?
Posted on 2013-06-25
I have a rtf file that contains some text and would like to read and parse its contents and probably load them in database.
I can read and process txt files using StreamReader's readline method. but when I try the same thing on rtf file it adds formatting and some non-readable text in the data string so the end result is not what I expect.
How can I process this rtf file? Would I need to manually copy the content of this rtf file and paste it in txt file before processing or is there a better way to directly process rtf files?
using (StreamReader sr = new StreamReader(FileName))
// Read and display lines from the file until the end of
// the file is reached.
while ((strInputRcd = sr.ReadLine()) != null)