I’m making a map creator that chooses images randomly from various sets. What I’m trying to do is set up subfolders in Resources and put the different images in each folder – e.g., a folder for streets, a folder for monuments, etc. Then I just make an array of images out of the files in the folder, and pick one.
For some reason, I can’t find a simple way of getting at the subfolders. I’ve tried using IO.Path.GetFullPath(My.Resources.ResourceManager.BaseName) and appending the folder name to the end of it, but no luck.
Is there some other way of getting the path? Is it even possible to use subfolders of Resources? Is there a better way of doing what I’m trying to accomplish? I’d really like to avoid creating the image arrays by hand.
It is quite unclear to me how you created subfolders for Resources. Which is probably the source of your problem. My.Resources refers to resources that you add in the Project + Properties, Resources tab. Those resources get embedded into your program, they become part of the assembly itself. You can’t get a path for it such a resource, it isn’t a file. You have to use My.Resources.ResourceManager to retrieve them, it uses Assembly.GetmanifestResourceStream() internally to get to the embedded data inside the assembly.
Not sure where you want to go with this, but if you actually want to use files in a folder instead of an embedded resource then you should not use My.Resources. Doing this is a bit of a hassle because you have to copy the files from your project directory to the bin\Debug and bin\Release directory. Using My.Resources is usually the preferred solution, especially since the user doesn’t get ready access to your art, but it doesn’t let you organize the resources into folders. Let us know what you really want to do.