The topic is the question, is there a way to access embedded resources folder by name dynamically via string? The closest I think I've gotten is the following code which has error "Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<string>' to 'string'", if i try to get the only folder it should return with [0] it gives error "Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<string>'"

string prefix = "namespace.folder."

var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames().Where(name => name.StartsWith(prefix));

Any help would be much appreciated,

2 Years
Discussion Span
Last Post by ddanbe

Just running
var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
and watching with the debugger gave me this:

    resourceNames   {string[2]} string[]
    [0] "WindowsFormsApplication3.Properties.Resources.resources"   string
    [1] "WindowsFormsApplication3.Form1.resources"  string

Hope it helps a bit.

Votes + Comments
Thank you for bringing up the array aspect, lacking quite a bit of sleep atm! Cheers

Sorta what i came to as well. But by using Assembly.GetExecutingAssembly().GetManifestResourceNames().Where(name => name.StartsWith(prefix)) you can specify a set of the resources that contain the prefix. Afterward I could run resourceNames through a for or foreach to find what im looking for with resourceNames.ElementAt(i)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.