Find all embedded resources in another assembly

SharpShade picture SharpShade · Jul 7, 2012 · Viewed 13.2k times · Source

I'm working on localization for my project. For this, I have a class which should load an embedded resource from another assembly, and then read out the strings.

But also I need to know which resource files this assembly contains. The number and which languages those are, is unknown.

So how do I find out how the ".resx" file in this assembly is named? Those all have the same scheme: "de-DE.resx", "en-US.resx", and so on.

I need to know how many of those files are contained in this assembly, and which languages they are.

I know that the ResourceManager has access to them, thus it should be possible to access this information programatically too...

Answer

kmatyaszek picture kmatyaszek · Jul 7, 2012

You should use GetManifestResourceNames method from Assembly class (msdn):

string[] resourceNames = this.GetType().Assembly.GetManifestResourceNames();
foreach(string resourceName in resourceNames)
{
    Console.WriteLine(resourceName);
}