Creating .exe file containing app data + PictureBox problem

Posted by Roydoron under C# on 3/28/2013 | Points: 10 | Views : 943 | Status : [Member] | Replies : 1
Hello Everyone,

I have two problems with my Winforms application.

In my app im reading from a folder that contains 1000 photos.

1. Each time Im running my app, I programed it to read the photos stored in a specific folder and put them in a DB (Dictionary<string, Image>), using:
            dI = new DirectoryInfo(@"C:\Users\Me\Desktop\Photos");
fileInfos = dI.GetFiles("*.jpg", SearchOption.TopDirectoryOnly);
foreach (FileInfo fi in fileInfos)
{
DB.Add(Path.GetFileNameWithoutExtension(fi.FullName), Image.FromFile(fi.FullName));
}


but when im trying to place a photo in a pictureBox using:
pictureBox4.BackgroundImage =  DB["PhotoName"];


It shows nothing, blank.

that's a drawback, CAUSE,

2. I want to use this app in other computers using only the .exe file that stored in the ..\bin\debug\
without each time changing the path the photos are stored...

So, how do I create an .exe file for my app that already has all the photos? without worring about them? (problem no' 2)

And, how to make sure the photos are shown (problem no' 1)

Thank you all!




Responses

Posted by: Roydoron on: 3/28/2013 [Member] Starter | Points: 25

Up
0
Down
hey jitendra kumar,

First, the dynamic you proposed is not working. I put the photos folder in c:\ and tried
 @"~\photos\
and its not working...
Second,
pictureBox4.BackgroundImage = DB["PhotoName"];-here need to specify DB["PhotoName"]+".jpg";
is not working either, I cant have a string concat to an image..

any other thought?



Roydoron, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response