0

![enter image description here][1]i have a windows application in C# with a setup project !!! I used Image.FromFile("filename") in my application but when make a setup project from it , and run it , it dose not show my pictures ! why ?

try
            {
                string timeOfDay = Convert.ToInt32(DateTime.Now.TimeOfDay.ToString().Substring(3, 2)).ToString();
                this.BackgroundImage = Image.FromFile("BackGround\\Flowers (" + timeOfDay + ").jpg");
            }
            catch (Exception ex)
            {
                this.BackgroundImage = Image.FromFile("\\BackGround\\Flowers (59).jpg");

            }
Mina
  • 21
  • 8

1 Answers1

0

First you have to add the Image file to your Visual Studio project unless you do this image can not be embedded into the output assembly.

Project Folder > Images

First add a custom folder and move your image to that folder and add the same folder to your VS project. now go to Image property and set the Build Action as "Resource".

Kurubaran
  • 8,696
  • 5
  • 43
  • 65
  • @Mina Can you show where you added that folder to VS project and the path you are using to refer that image ? – Kurubaran Dec 02 '13 at 10:41
  • i added code to question . it works correctly in application but it dosnt work in exe version – Mina Dec 02 '13 at 11:01
  • @Mina So did you add a folder to your project called BackGround ? and moved the images there ? – Kurubaran Dec 02 '13 at 11:40