Finding .BMP's and .JPEG's after deployment
-
If I have an application that uses the FromFile("Pathname") method, how can that code recognize where to find that file on another computer. For example, if I want to display a picture that I'm developing on my computer and I use the FromFile("C:\my Bitmaps\Pic.bmp") that's all fine and dandy. But if I were to install that application on another computer, and when deployed, generically dumps every dependent file into "C:\Program Files\WindowsApplication1", the path I originally gave to find the Bitmap "C:\my Bitmaps\Pic.bmp" will no longer be valid. How can I make it so that when the application is installed on another computer, all the paths will be correct? Thank you The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
-
If I have an application that uses the FromFile("Pathname") method, how can that code recognize where to find that file on another computer. For example, if I want to display a picture that I'm developing on my computer and I use the FromFile("C:\my Bitmaps\Pic.bmp") that's all fine and dandy. But if I were to install that application on another computer, and when deployed, generically dumps every dependent file into "C:\Program Files\WindowsApplication1", the path I originally gave to find the Bitmap "C:\my Bitmaps\Pic.bmp" will no longer be valid. How can I make it so that when the application is installed on another computer, all the paths will be correct? Thank you The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
I am not sure I understood your question correcty, but: 1. If the user wants to open an arbitrary picture on your program, you can use the OpenFileDialog class to get the path and then use that path on Bitmap.FromFile() method. 2. If you are talking about :)a picture that you want to distribute with your program, install it in the same directory as your executable and use something like Application.StartupPath + "\pic.bmp" or embbed it in the executable.
-
I am not sure I understood your question correcty, but: 1. If the user wants to open an arbitrary picture on your program, you can use the OpenFileDialog class to get the path and then use that path on Bitmap.FromFile() method. 2. If you are talking about :)a picture that you want to distribute with your program, install it in the same directory as your executable and use something like Application.StartupPath + "\pic.bmp" or embbed it in the executable.
I think the second option is the one I was looking for. Let's say under the Form_Load event, I want the form to open up with a picture. On my computer, the picture is located at C:\my pics\Pic.bmp, but if I were to install this program at on another person's computer, it would install at the default location C:\Program Files\WindowsApplication1\Pic.bmp, and when he would try to run the program, it would not find the picture because my code is looking for C:\my pics\Pic.bmp, not the other path. So instead of using BitMap.Fromfile("Path") just use Application.StartupPath & "\Pic.bmp" ? Also, how could I embed a picture or a WAV into the executable? thanks The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
-
I am not sure I understood your question correcty, but: 1. If the user wants to open an arbitrary picture on your program, you can use the OpenFileDialog class to get the path and then use that path on Bitmap.FromFile() method. 2. If you are talking about :)a picture that you want to distribute with your program, install it in the same directory as your executable and use something like Application.StartupPath + "\pic.bmp" or embbed it in the executable.
I think the second option is the one I was looking for. Let's say under the Form_Load event, I want the form to open up with a picture. On my computer, the picture is located at C:\my pics\Pic.bmp, but if I were to install this program at on another person's computer, it would install at the default location C:\Program Files\WindowsApplication1\Pic.bmp, and when he would try to run the program, it would not find the picture because my code is looking for C:\my pics\Pic.bmp, not the other path. So instead of using BitMap.Fromfile("Path") just use Application.StartupPath & "\Pic.bmp" ? Also, how could I embed a picture or a WAV into the executable? thanks The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
-
I think the second option is the one I was looking for. Let's say under the Form_Load event, I want the form to open up with a picture. On my computer, the picture is located at C:\my pics\Pic.bmp, but if I were to install this program at on another person's computer, it would install at the default location C:\Program Files\WindowsApplication1\Pic.bmp, and when he would try to run the program, it would not find the picture because my code is looking for C:\my pics\Pic.bmp, not the other path. So instead of using BitMap.Fromfile("Path") just use Application.StartupPath & "\Pic.bmp" ? Also, how could I embed a picture or a WAV into the executable? thanks The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew
If you include that Bitmap in the project directory, you can then include it in your project and select Build Action to embedded resource in the properties window. To retrieve the embedded bitmap you would use the overloaded constructor Bitmap(Type type, string resource), where the parameters type would be ME.GetType() and resource would be "myBitmap.bmp". If you choose the Build Action as content, it will be installed in your program's directory in the user's computer and you can use a relative path to it: Bitmap(string path) where path is just the full name (myBitmap.bmp). As to the wave file, it can also be embeded if you include it in the project and set the build action to embeded. Then to retrieve it, the only option I see is to retrieve it as a raw stream (using the GetManifestResourceStream, for instance), but maybe there some other way to retrieve it that I am not aware of.
-
If you include that Bitmap in the project directory, you can then include it in your project and select Build Action to embedded resource in the properties window. To retrieve the embedded bitmap you would use the overloaded constructor Bitmap(Type type, string resource), where the parameters type would be ME.GetType() and resource would be "myBitmap.bmp". If you choose the Build Action as content, it will be installed in your program's directory in the user's computer and you can use a relative path to it: Bitmap(string path) where path is just the full name (myBitmap.bmp). As to the wave file, it can also be embeded if you include it in the project and set the build action to embeded. Then to retrieve it, the only option I see is to retrieve it as a raw stream (using the GetManifestResourceStream, for instance), but maybe there some other way to retrieve it that I am not aware of.
Thanks A lot! The application.StartupPath namespace worked like a charm! The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew