Case: I have a Desktop application in which I need to show Customized Images as per Logged In Vendor. So, in App.config, the image file is added as a key:
<add key="Logo" value="companylogo_2.jpg"/>
How to consume it in ToolstripLabel control?
Note: In App.config file, value does not contain full path of image, just the Name of Image
Trials:
1.
smallImageList.Images.Add(Image.FromFile(ConfigurationSettings.AppSettings["Logo"]));
2.
string CurrDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
smallImageList.Images.Add(Image.FromFile(Path.Combine(CurrDirectory,ConfigurationSettings.AppSettings["Logo"])));
Thanks for zero Help! Anyways, I figured it out.
Steps :
Read the value from
App.config:Get full path using :
Assembly.GetExecutingAssembly().Locationas:Assign value to
toolStripLabelas: