Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Get list of resources from a ResourceManager

Back to Forum: Tech Off
  • User profile image
    GurliGebis

    I'm trying to get a list of strings out of a ResourceManager with the names of all the resources.
    It contains icons only.

    I'm using .NET 2.0 Beta 2 and writing it in C# .
    Anybody who have an idea?

  • User profile image
    Skibum

    In the .NET Framework v2.0 you can use a class called ResourceSet in the System.Resources namespace.  You new up a ResourceSet providing the Resource File Name in the constructor then you have access to the resources by enumerating through the ResourceSet.

    Some sample code off the top of my head...


    public void GetResources()
    {
          ResourceSet resources = 
             new ResourceSet("theresourcefile.resources");

          //enumerate through the ResourceSet
          IDictionaryEnumerator enumerator = 
             resources.GetEnumerator();

          while(enumerator.MoveNext())
          {
                Console.WriteLine(enumerator.Key);
          }
          
    }

    This is one approach to reading ALL the Resource Keys available!

  • User profile image
    GurliGebis

    Thanks, now how do I get them add into a String[] ? (Somehow I cannot get ArrayList to accept Generics, so I cannot just put the key into there and run toArray on it).

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.