2

Is there a way to read rtf files into a string and then replace some patterns on them? Ideally I would want to save the new string into an rtf file again and open from wordpad. All I see is the richtextbox solution which i would like to skip.

I used to do that with, Microsoft.Office.Interop, by creating Word.Application then Word.Document then oDoc.Content.Find.Execute(FindText:="[[Blah Blah]]", ReplaceWith:="", Replace:=Word.WdReplace.wdReplaceAll) but I realize that Word might not always be installed on client...

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
dr.doom
  • 480
  • 1
  • 6
  • 17
  • Why do you want to skip the RichTextBox solution? – Aaron McIver Feb 02 '12 at 16:28
  • Do you want to edit the RTF text manual (e.g., in a TextBox) or programatically using code (e.g., File.ReadAllText, string.Replace, File.WriteAllText)? – Polyfun Feb 02 '12 at 16:36
  • There is no point using RichTextBox, because I don't want to give the user the possibility to write or change anything... – dr.doom Feb 02 '12 at 16:39
  • I just want to programmatically find and replace some specific text sequences like [[Blah]] with something like 1233... – dr.doom Feb 02 '12 at 16:40

1 Answers1

1

Microsofts suggests using the RichTextBox control as documented here. This seems to be used by other members as mentioned in this thread.

However, there are some other solutions such as NRTFTree.

Community
  • 1
  • 1
Till Hoffmann
  • 9,479
  • 6
  • 46
  • 64