Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4012862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:18:00+00:00 2026-05-20T09:18:00+00:00

One level up from this question , what would be the way to store

  • 0

One level up from this question, what would be the way to store all (and loop through) available resources and associated cultures, to allow user selection of a specific culture?

Further explanation:

Suppose three resource files:

  • GUILanguage.resx
  • GUILanguage.fr.resx
  • GUILanguage.it.resx

I could have a string in each called LanguageName. How would I be able to programmatically loop through the different LanguageName values to list them (in say a list box)?

EDIT: WinForms project, embedded resources.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:18:01+00:00Added an answer on May 20, 2026 at 9:18 am

    Here is a solution I think works for Winforms:

    // get cultures for a specific resource info
    public static IEnumerable<CultureInfo> EnumSatelliteLanguages(string baseName)
    {
        if (baseName == null)
            throw new ArgumentNullException("baseName");
    
        ResourceManager manager = new ResourceManager(baseName, Assembly.GetExecutingAssembly());
        ResourceSet set = manager.GetResourceSet(CultureInfo.InvariantCulture, true, false);
        if (set != null)
            yield return CultureInfo.InvariantCulture;
    
        foreach (CultureInfo culture in EnumSatelliteLanguages())
        {
            set = manager.GetResourceSet(culture, true, false);
            if (set != null)
                yield return culture;
        }
    }
    
    // determine what assemblies are available
    public static IEnumerable<CultureInfo> EnumSatelliteLanguages()
    {
        foreach (string directory in Directory.GetDirectories(AppDomain.CurrentDomain.BaseDirectory))
        {
            string name = Path.GetFileNameWithoutExtension(directory); // resource dir don't have an extension...
    
            // format is XX or XX-something, we discard directories that can't match.
            // could/should be replaced by a regex but we still need to catch cultures errors...
            if (name.Length < 2)
                continue;
    
            if (name.Length > 2 && name[2] != '-')
                continue;
    
            CultureInfo culture = null;
            try
            {
                culture = CultureInfo.GetCultureInfo(name);
            }
            catch
            {
                // not a good directory...
                continue;
            }
    
            string resName = Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location) + ".resources.dll";
            if (File.Exists(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, name), resName)))
                yield return culture;
        }
    }
    

    And here is how you would use it for a WindowsFormsApplication1:

        List<CultureInfo> cultures = new List<CultureInfo>(EnumSatelliteLanguages("WindowsFormsApplication1.GUILanguage"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This has to be a common question that all programmers have from time to
First of all I'm sorry if you feel this question has been raised before,
I've looked at a bunch of resources provided by similar questions asked on this
Note: I ended up answering my own question shortly after posting this. Thanks and
imagine something like this: import class B.*; interface A supports A.testSum { int sum(
Just when I thought I've understood this topic completely, I'm back to basics. I
I recently joined this organisation that I am currently working at that has asked
I have a cube with a typical snapshot structure and daily granularity (like inventory
OK, first, I dont want any kind of flamewar here or anything like it.
I'm trying to get to grips with how Lua works, and how it can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.