The_Little_Cousin
The_Little_Cousin

Reputation: 58

How to save a Picture to a Picturebox?

Here's the current code I have:

private void BrowsePicture_Click(object sender, EventArgs e) // Browse Picture
    {
        OpenFileDialog OFD = new OpenFileDialog();
        if(OFD.ShowDialog()==DialogResult.OK)
        {
            Bitmap Image = new Bitmap(OFD.FileName);
            ProfilePicture.Image = Image;
            ProfilePicture.SizeMode = PictureBoxSizeMode.Zoom;
        }
    }

I would like to save the image on the PictureBox so that when the software is closed and opened again later, the image will still be in there. Can this can be done through Properties.Settings?

Upvotes: 1

Views: 381

Answers (1)

Nataniel Richardt
Nataniel Richardt

Reputation: 232

Where are you saving this data? You should save your setting in a place that you can read when you do the login action and then set the value in your PictureBox.

EDIT:

To save the image in your specific folder:

Bitmap b = new Bitmap("your image location"); b.Save("your folder location + your image name with extension");

To read the image and set into your PictureBox do this in the Load event:

pictureBox1.Image = Image.FromFile("your image location");

Upvotes: 2

Related Questions