Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, September 3, 2012 6:25 AM
Hi All,
in my soluction explorer i created a folder called Images
and i placed BlueHills.jpg image in that folder
i want to place this image to picturebox
i tried the following code
pictureBox1.Image = Image.FromFile(@"..\Images\BlueHills.jpg");
but it wont works
can you please tell me how to slove this issue.?
Thanks,
Murali.
programmer on .net
All replies (5)
Monday, September 3, 2012 9:09 AM âś…Answered
Follow following steps:
1. As shown in screenshot below, in the property window for your image file, Set "Copy to Output Directory" to "Copy Always". Also, if it's NOT already set so, set the "Build Action" to "Content".
2. Don't use '~' and/or '\ and simply try with following:
pictureBox1.Image = Image.FromFile(@"Images\BlueHills.jpg");HTH.
If this answers your question, please Mark it as Answer. If this post is helpful, please vote as helpful.
Monday, September 3, 2012 6:43 AM
Please check the folder structure of your project and make sure your image is in the right folder or not.
As per my understatnding your absolute path is right. any way please try like this
pictureBox1.Image = Image.FromFile(@"~\Images\BlueHills.jpg");
With Thanks and Regards
Sambath Raj.C
click "Proposed As Answer by" if this post solves your problem or "Vote As Helpful" if a post has been useful to you
Happy Programming!
Monday, September 3, 2012 6:45 AM
You have to give path with respect to where your EXE resides.
If you are using Windows Special Folders, then there is an easier way to get to windows special folder.
http://msdn.microsoft.com/en-us/library/14tx8hby.aspx
Viral.
MCTS - WPF, WinForms, Sql Server 2008
Monday, September 3, 2012 6:53 AM
Hi Sambath,
Its not working for me
and i tried like this one also
pictureBox1.Image = Image.FromFile(@"~\WindowsFormsApplication1\Images\BlueHills.jpg");
but it is not working
programmer on .net
Monday, September 3, 2012 9:17 AM
Hi,
Try the below...
string fullPath=Server.MapPath("/images/image.jpg");
** Image.FromFile(@fullPath);**
Regards - Rajasekhar.R ' Don't forget to mark the post as answer or vote as helpful if it does,