× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Retrieve image and display in picturebox with image path stored in database c#

Praveen Paulose
Apr 20, 2015
<p>You need to provide the full path to your image to the <code>PictureBox</code>. The relative path <code>Images\ac.jpg</code> will not work. You need an absolute path like <code>C:\Images\ac.jpg</code></p> <p>If your Images folder is where your executable is you can try creating the absolute path as shown below</p> <pre><code>string absolutePath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @"Images\ac.jpg"); pbCoffeeImage.Image = System.Drawing.Image.FromFile(absolutePath); </code></pre> <p>If you are going to allow the user to input the image path, I would recommend you use the <code>FileDialog</code> control to make sure the path is valid and an absolute path.</p> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/29735229/Retrieve%20image%20and%20display%20in%20picturebox%20with%20image%20path%20stored%20in%20database%20c#/29735287">Stack Overflow</a>.</p>
comments powered by Disqus