Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Finding .BMP's and .JPEG's after deployment

Finding .BMP's and .JPEG's after deployment

Scheduled Pinned Locked Moved Visual Basic
questioncomgraphicssysadmintutorial
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jm6k
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • J Jm6k

      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

      A Offline
      A Offline
      apferreira
      wrote on last edited by
      #2

      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.

      J 2 Replies Last reply
      0
      • A apferreira

        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.

        J Offline
        J Offline
        Jm6k
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • A apferreira

          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.

          J Offline
          J Offline
          Jm6k
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • J Jm6k

            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

            A Offline
            A Offline
            apferreira
            wrote on last edited by
            #5

            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.

            J 1 Reply Last reply
            0
            • A apferreira

              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.

              J Offline
              J Offline
              Jm6k
              wrote on last edited by
              #6

              Thanks A lot! The application.StartupPath namespace worked like a charm! The Jazz Master 6000 DJ Badknees Parma Grind Crew - www.geocities.com/parmagrindcrew

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups