Created
March 5, 2019 23:29
-
-
Save karoltheguy/9594aad775ffcdda72080a8710266f5a to your computer and use it in GitHub Desktop.
Convert RTF file content to plain text string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| string path = @"C:\test\test rich.rtf"; | |
| System.Windows.Forms.RichTextBox rtBox = new System.Windows.Forms.RichTextBox(); | |
| // Get the contents of the RTF file. Note that when it is | |
| // stored in the string, it is encoded as UTF-16. | |
| string s = System.IO.File.ReadAllText(path); | |
| // Convert the RTF to plain text. | |
| rtBox.Rtf = s; | |
| Console.WriteLine(rtBox.Text); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment