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"?
A:
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).
Russ
2010-08-19 12:50:16
+1
A:
You probably want to think about making your image an embedded resource. This will embed it in the exe. This article should explain it.
Tim
2010-08-19 12:53:54
+1
A:
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
Emiswelt
2010-08-19 12:55:23
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
2010-08-19 13:40:52
THanks, I used this to help: http://www.csharp411.com/embedded-image-resources/
rd42
2010-08-19 13:44:36
Glad it worked out for you :)
Emiswelt
2010-08-19 13:46:45