I have an image in my project that I want to go along with the program. If I was going to use something like BitmapImage() what would I use for the path? I don't want to use the c:\blah blah blah because that could change depending on were it is on each PC. Is it called a "relative path"?
4 Answers
You can and also should put your images into the projects resoucre-file (embed it).
Then, you can access your resource at runtime like any other object.
System.Drawing.Bitmap bitmap1 = myProject.Properties.Resources.Image01;
Look at this MSDN page for more information: http://msdn.microsoft.com/en-us/library/7k989cfy%28VS.80%29.aspx

- 3,909
- 1
- 38
- 56
-
I made a bitmap by clicking on my project folder and selecting add bmp and tried to use uploadImage.Source = myProjectProperties.Resources.Bitmap1.bmp; and it said myProject.Properties.Resources does not contain a definition for Bitmap1.bmp – rd42 Aug 19 '10 at 13:40
You probably want to think about making your image an embedded resource. This will embed it in the exe. This article should explain it.

- 21,297
- 6
- 52
- 68
You want to use Environment.CurrentDirectory, or System.Reflection.Assembly.GetExecutingAssembly().Location (which is the location of the executable--you can use System.IO.FileInfo to get to the directory).

- 4,091
- 21
- 32
If you want to save the file to the users profile so it will be in the same location no matter where the application is you can get the path with the following
string s = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

- 1
- 1