I have an image in Windows Form Solution. After the user selects an item from the database, I want to load the image into this window. The file name will be obtained from the database, and all images should be saved in a subfolder of the application folder (\ Images). I do not want to include all of these (2000-3000 images) in my solution, in addition, more images will be added by users as the database grows. Also, I do not want to encode the absolute path. So this is not what I want:
pictureBox.Image = Image.FromFile(@"C:\Program Files\Application\Images\" + dbase.filename);
I want to encode the relative path to the image folder, so no matter where the application is installed, images can be downloaded from this particular subfolder. I tried such things using a temporary test image called "test.jpg":
pictureBox.Image = Image.FromFile(@"Images\test.jpg");
pictureBox.Image = Image.FromFile(@"..\Images\test.jpg");
pictureBox.Image = Image.FromFile(@"|DataDirectory|\Images\test.jpg");
But that will not work. I can get it to work with an absolute path, for example "C: \ Images \ test.jpg". What should I do?
Ivo77 source
share