Extract image and display in window with image saved in C # database

I have image paths stored in my database under the Image column in format Images\ac.jpg. The path is already stored in the text box with the name txtImage.Text. I try to display it in a control, but I get the following error:

An unhandled exception of type "System.IO.FileNotFoundException" occurred in System.Drawing.dll

Additional Information: Images \ ac.jpg

pbImage.Image = System.Drawing.Image.FromFile(txtImage.Text);
+4
source share
2 answers

PictureBox. Images\ac.jpg . , C:\Images\ac.jpg

"" , , .

string absolutePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Images\ac.jpg");

pbCoffeeImage.Image = System.Drawing.Image.FromFile(absolutePath);

, FileDialog, , .

+4

Images\ac.jpg - , . , (workingPath\Images\ac.jpg) . , "" .

+2

All Articles