Insert an image into RTF document in C#
问题 I am creating a RichTextBox subclass that can insert images easily. I referred to this question to start, but I can't get the generated RTF string to work. When I try to set the SelectedRtf of the RTB, it errors out with "File format is not valid." Here is my code: internal void InsertImage(Image img) { string str = @"{\pict\pngblip\picw24\pich24 " + imageToHex(img) + "}"; this.SelectedRtf = str; // This line throws the exception } private string imageToHex(Image img) { MemoryStream ms = new