0

string address = PictureBox.Location;

give the location of Picturebox image source.

How get address of Picturebox's image source in this order:

C:\\ABC\\XYX\\image.png

The PictureBox load with:

    using (MySqlDataReader dr = cmd.ExecuteReader())
    {
        while (dr.Read())
        {
            using (MemoryStream stream = new MemoryStream())
            {
                if (dr["IMAGE"] != DBNull.Value)
                {
                    byte[] image = (byte[])dr["IMAGE"];
                    stream.Write(image, 0, image.Length);
                    Bitmap bitmap = new Bitmap(stream);
                    pictureBox.Image = bitmap;
                }
            }
        }
    }

I did try this one and doesn't help.

string strFileName = PictureBox.ImageLocation + @"\ImageOne.JPG";

Also tried this:

pictureBox.Image.Save("D:\\ImageOne.JPG", ImageFormat.Jpeg);

Gives me this error:

A generic error occurred in GDI+. at System.Drawing.Image.Save

Thanks.

SDG69
  • 161
  • 1
  • 4
  • 19
  • That URL order is needed for AutoCAD insert image with C# – SDG69 Apr 29 '19 at 08:27
  • Did you read that file before? (You can't overwrite if any handle to the image is still anywhere in use) - Also: Did the image show in the pbox? – TaW Apr 29 '19 at 08:39
  • Note that pbox doesn't know about the miage source path. – TaW Apr 29 '19 at 08:45
  • @TaW, Yes, image show in pbox, but how unload pbox while winform need to display pbox's image. – SDG69 Apr 29 '19 at 10:09
  • The last line of code should work, at least if the name is new and you have write right for the drive's root. Setting the location is useless, though. Not sure what you mean by 'unload'.. – TaW Apr 29 '19 at 10:13
  • @TaW, TaW:"You can't overwrite if any handle to the image is still anywhere in use" meant to me unload;) also all codes works in winForm but winForm in Autodesk AutoCAD is another story! – SDG69 Apr 30 '19 at 04:02

0 Answers0