Solution 1: Create a dedicated folder for storing the images
in your project debug/release
folder.
Ex: project/bin/Release/Images/
Access the Images from that folder as below:
String FullPath=System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "")+"\\Images\\Blue_Style1.jpg";
this.BackgroundImage =Image.FromFile(FullPath);
Solution 2: accessing Images
from Resources
file.
Note: first you need to add the Images
into Resources
.
Here i have added Blue_Style1.jpg
file to Resources
.
this.BackgroundImage = Properties.Resources.Blue_Style1;
See here for adding images to Resources