-1

I am trying to save an image using SaveFileDialog together with some text. the image is in a picturebox and everything is inside a rich textbox.

When I try to save the text save succesfully but the image does not.

Please Help

  SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Title = "Open file";
        saveFileDialog.Filter = "RTF files (*.rtf)|*rtf| All Files (*.*)|*.*";
        saveFileDialog.DefaultExt = ".rtf";
        //om man trycker på OK
        if (saveFileDialog.ShowDialog() == DialogResult.OK)
        {//skriv datan till en ny fil
            StreamWriter write = new StreamWriter(File.Create(saveFileDialog.FileName));

            write.Write(richTextBox1.Text);

            write.Dispose();
        }
Alexander
  • 9
  • 2
  • 1
    How can `PictureBox` be inside `RichTextBox`? That makes no sense. – Dialecticus Feb 26 '20 at 19:42
  • 1
    If the image is in a PictureBox, then you need a separate saving operation for that. If the image is in the RichTextBox (no PictureBox), then you can't use the Text property. You would have to use the Rtf property. – LarsTech Feb 26 '20 at 19:44
  • This is not supported. – TaW Feb 26 '20 at 20:06
  • [How can I insert an image into a RichTextBox?](https://stackoverflow.com/q/542850/7444103) -- [Insert Plain Text and Images into RichTextBox at Runtime](https://www.codeproject.com/Articles/4544/Insert-Plain-Text-and-Images-into-RichTextBox-at-R) (many others). – Jimi Feb 26 '20 at 21:00

1 Answers1

0

I think you should use Bitmap.Save() method;

pictureBox.Image.Save(yourPath);

Hope it works for you.

Jakub Sluka
  • 123
  • 1
  • 14