"deerchao" <de******@gmail.comwrote in message
news:11**********************@22g2000hsm.googlegro ups.com...
Is there any way I can get all resource keys with in a compiled and
embedded resx file?
Thanks!
This can be done by enumerating the keys of the underlying ResourceSet. See
below for a sample function (C# 2.0 and later).
private IEnumerable<stringGetResourceNames(string name)
{
return GetResourceNames(name, Assembly.GetExecutingAssembly());
}
private IEnumerable<stringGetResourceNames(string name, Assembly assembly)
{
ResourceManager rm = new ResourceManager(name, assembly);
ResourceSet rs = rm.GetResourceSet(CultureInfo.CurrentUICulture, true,
true);
IDictionaryEnumerator ide = rs.GetEnumerator();
while (ide.MoveNext())
{
yield return (string)ide.Key;
}
}
Sample code:
foreach (string key in GetResourceNames("RD.Properties.Resources")) // This
is the fully qualified name of the resource set
{
// Do something with key...
}
Best Regards,
Stanimir Stoyanov
www.stoyanoff.info |
www.aeroxp.org