Click here to Skip to main content
16,018,057 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
I have one picturebox in my windows form.In that i will retrieve image from database & set that image in picturebox.i want to find path of that picturebox image.
Posted
Comments
[no name] 27-Sep-13 8:13am    
If the image is in your database then the path is the same as the path to your database....
Rohini Shirke 28-Sep-13 0:01am    
on picturebox click event I have set image to picture box & also path of taht image file is also dispayed in textbox.
private void pbStudImg_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog of = new OpenFileDialog();
of.Filter = "Image Files|*.jpg";
if (of.ShowDialog() == DialogResult.OK)
{
txtImage.Text = of.FileName;
pbStudImg.Image = Image.FromFile(of.FileName);
}
}
catch (Exception ex)
{
MessageBox.Show("Error :" + ex.Message);
}
}
On save button click i will save the picturebox image in mysql database table.this is done..But On Get button click i want that image & path from database..Image is retrived & displayed in picturebox but path will not get???

1 solution

If your purpose is limited to showing the image in the picturebox you don't need any path, you only need to create one image instance with the data retrieved from the database and assign it to the picturebox's Image property.

C#
byte[] ImageData = <the image="" bytes="">
using (MemoryStream Stream = new MemoryStream( ImageData ))
{
    pictureBox1.Image = Image.FromStream( Stream );
} </the>


V.Lorz
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900