There is an array of bytes representing RTF-text (tagged) containing images. How to get a string from it? I used Encoding.Default , then I overtook RichTextBox and saved to a file - I received only text on the output, without attachments.

  • So what's the problem? Want out of Rich is not in the text file? Or Rich does not fulfill the task? - Chad
  • The problem is that I want to get not only the text, but also the packie contained there and other investments - megafonishe
  • Kakby to convert to a string is just a preparation, and then rummage through conflicting specs and disassemble RTF elements. - karmadro4

1 answer 1

Try this:

 string str = Encoding.UTF8.GetString(byte_array, 0, byte_array.Length); 

The result is written directly to the file.

Although, of course, depends on how you coded it.

  • No no. The RTF markup itself consists of ASCII (Latin-1). - karmadro4
  • Well then: Encoding.ASCII.GetString You tell me how you got an array of bytes, then the answer will become obvious. - michael
  • The byte array is the body of the Outlook task, Outlook.TaskItem, the RTFBody property. UTF8 and ASCII issued question marks instead of Cyrillic, otherwise everything else is the same) - megafonishe
  • Did you receive pictures in RichTextBox (or are they not there at all)? You also need to delve into the study of the format of RTF, I guess that the pictures are separate binary code from the text (perhaps after all the text). And convert the binary code of the picture into a picture. Also, if this is a pure rtf, then after saving it to a file, you should get a full-fledged * .RTF. You also did not mention where it is all necessary to put. - Michael