Results 1 to 8 of 8

Thread: Resource Folder/Publishing Question

  1. #1

    Thread Starter
    Hyperactive Member neef's Avatar
    Join Date
    Dec 2001
    Location
    Boston
    Posts
    311

    Resource Folder/Publishing Question

    I have been using Image.FromFile to display jpegs and other image files. For the first time I'm beginning to publish my program, but I get errors about not finding the pictures I want to see using Image.FromFile.

    This may be an obvious question, but I'm just trying to understand the basics of publishing: I should import every resource that I plan on using correct? I can't just use Image.From file and expect it to work when published right?

    Thanks
    Intermediate Level Programmer Extraordinaire

  2. #2

    Thread Starter
    Hyperactive Member neef's Avatar
    Join Date
    Dec 2001
    Location
    Boston
    Posts
    311

    Re: Resource Folder/Publishing Question

    All right, so I did some research on embedding resources, which isn't what I want to do in my circumstance. I just need to make sure the pictures are in the exact same file directory on both my development machine and on the user's machine if I use Image.FromFile.
    Intermediate Level Programmer Extraordinaire

  3. #3
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Music city, U.S.A.
    Posts
    1,253

    Re: Resource Folder/Publishing Question

    The way we do it in our application is that the main app directory has a /bin folder where the .exe - and all the other dll's - are stored. There are other directories in the project as well, and we refer to those directories in our application using the "../" prefix. This tells windows to look up one directory from where the exe resides and then start looking for the file.

    So in your case, you would have a directory structure say like this:

    c:\program files\your app\bin
    c:\program files\your app\images
    ... maybe some other directories as well.

    Then, when referring to a file in the images directory, you would use the path "../images/image1.gif".

    OK. So that's when it's installed. How do you make this work in development? Well, by default the compiled .exe or .dll will go to the obj/debug directory, but it doesn't have to be that way. Under project settings, you can tell VS where to put the .exe. So you setup a directory structure on your system that mirrors what will be when installed, and tell your application to put the compiled exe there. That way, when you run the app in the dev environment to test some code, it will put the .exe in the proper place and the .exe will know, via the relative path, where to find the files.

    Clear as mud?
    I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Resource Folder/Publishing Question

    Why not extract the resource then?

    Code:
    My.Resources.sss.Save("C:\example.jpeg", Drawing.Imaging.ImageFormat.Jpeg)

  5. #5

    Thread Starter
    Hyperactive Member neef's Avatar
    Join Date
    Dec 2001
    Location
    Boston
    Posts
    311

    Re: Resource Folder/Publishing Question

    Quote Originally Posted by dolot View Post
    The way we do it in our application is that the main app directory has a /bin folder where the .exe - and all the other dll's - are stored. There are other directories in the project as well, and we refer to those directories in our application using the "../" prefix. This tells windows to look up one directory from where the exe resides and then start looking for the file.

    So in your case, you would have a directory structure say like this:

    c:\program files\your app\bin
    c:\program files\your app\images
    ... maybe some other directories as well.

    Then, when referring to a file in the images directory, you would use the path "../images/image1.gif".

    OK. So that's when it's installed. How do you make this work in development? Well, by default the compiled .exe or .dll will go to the obj/debug directory, but it doesn't have to be that way. Under project settings, you can tell VS where to put the .exe. So you setup a directory structure on your system that mirrors what will be when installed, and tell your application to put the compiled exe there. That way, when you run the app in the dev environment to test some code, it will put the .exe in the proper place and the .exe will know, via the relative path, where to find the files.

    Clear as mud?
    I had to read it a few times, but you do make sense, thanks. It's bit of isn't it?

    Thanks!
    Intermediate Level Programmer Extraordinaire

  6. #6
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Music city, U.S.A.
    Posts
    1,253

    Re: Resource Folder/Publishing Question

    Quote Originally Posted by ident View Post
    Why not extract the resource then?

    Code:
    My.Resources.sss.Save("C:\example.jpeg", Drawing.Imaging.ImageFormat.Jpeg)
    I have another app where we compile images in as resources like this. You actually don't have to extract the resources to a file, but can assign it straight to the image.

    Code:
    Me.ImagePanel.BackgroundImage = My.Resources.ImageResources.PointFrontWall
    I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

  7. #7
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: Resource Folder/Publishing Question

    Yeh i am well aware you don't have to extract resources. It was inline with what the OP asked for.

  8. #8
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Music city, U.S.A.
    Posts
    1,253

    Re: Resource Folder/Publishing Question

    Quote Originally Posted by ident View Post
    Yeh i am well aware you don't have to extract resources. It was inline with what the OP asked for.
    I understand - no offense meant.
    I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width