Results 1 to 4 of 4

Thread: Resource Folders

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Resource Folders

    Resource files loaded into VS are all placed into the one location.
    Is it possible to have folders?
    If A then look for resources in folder A else look in folder B

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Resource Folders

    I don't know what the limitations on this are, but I think the answer is a bit of yes and a bit of no, in this case. After all, the resources that you have in the solution could end up being brought along as part of the deployment, compiled into the exe, or something else. Does it really matter where they are located if they end up being compiled into the exe? And, for those that are not handled that way, you can certainly put them elsewhere. You can load them dynamically, even. Items in the resource folder can be there just for convenience, or more than that.

    EDIT: I guess my point is that you can kind of do whatever you want, but it matters a whole lot whether you are just trying to organize things in the project, or are thinking of a way to organize resources at runtime. In the latter case, there are tradeoffs to different solutions, but it is technically possible. I'm doing that with some icons and graphics, where there is a default that can be swapped out for items if they are found in some other folder on the computer. I would think that it would be ideal for localization files, as well, though I have never tried that.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    817

    Re: Resource Folders

    I'm only starting to understand how to deal with resource files. Ideally they are all compiled in the packaged executible.
    It seems that I can drag a folder into the solution explorer.
    Can I access those files as resources? And how would I access them?
    And will they be bound into the executatle file?

    If so, why is there a need for a Resources section in the project properties?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Resource Folders

    The whole point of resources is that they are compiled into the assembly. If you are deploying a loose file with your app then it's not a resource. You can put the source files in folders in your project if you want, but those folders are irrelevant to the resources once compiled.

    There are two ways to add resources. You can add a file to your project and set its Build Action to Embedded Resource, in which case you would also set Copy To Output Directory to Never Copy. You can also add a file on the Resources page of the project properties, in which case the file will be automatically added to your Resources folder. Resources added the second way are easier to access in code via My.Resources, so you should generally do it that way by default, doing it the first way only if you have a specific reason to do so.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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