Re: pictures in the program
1) Embed the picture as a resource.
or
2) Change the path to a relative one
Re: pictures in the program
How about this
Code:
System.IO.Path.GetFullPath(path)
??
Re: pictures in the program
use the app.config to hold a file path to the image directory
Re: pictures in the program
if you don't embed the image (which is what I'd suggest you do. vs 2005+ has a resource editor that makes doing this a brainless operation), then you can include an image folder relative to the exe folder.
Code:
string exeLocation = Assembly.GetExecutingAssembly().Location;
string exeDir = Path.GetDirectoryName(exeLocation);
string imageDir = Path.Combine(exeDir, "images");
string imageLocation = Path.Combine(imageDir, "mypic.png");
Re: pictures in the program
it is easier to do this:
Code:
pictureBox1.Image = System.Drawing.Image.FromFile("images/test.jpg");
images folder should be in the same folder that your exe file resides.
Re: pictures in the program
If I recall correctly (and I could be wrong), if you specify a path like that, it will use the working directory which isn't always the same as the executable path.
Re: pictures in the program
Quote:
Originally Posted by
MadHatter
If I recall correctly (and I could be wrong), if you specify a path like that, it will use the working directory which isn't always the same as the executable path.
That's correct, you are not wrong
Re: pictures in the program
You may also place the picture in the same folder as the exe & use this
string picPath = Application.StartupPath + "\\Pic.jpg"
Kind Regards,
Ali Bilal Yousaf