Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

C# ISOCurrencySymbol. How to change my windows enviromnent to report a different code

Options
  • 07-08-2012 3:13pm
    #1
    Registered Users Posts: 7,501 ✭✭✭


    Im currently using the below to report the current currency symbol of my server:

    string currencySymbol = RegionInfo.CurrentRegion.ISOCurrencySymbol;

    Currently its reporting as GBP because its a UK based server.
    I need to change it to that it reports as SEK for some testing.

    In regional settings of windows i have changed the format to be Swedish(Sweden) and i changed the location to be Sweden.

    However its still reporting the above as GBP.

    Where is this information received from?


Comments

  • Registered Users Posts: 1,235 ✭✭✭Odaise Gaelach


    From MSDN...
    MSDN.com - RegionInfo.CurrentRegion Property
    The RegionInfo class does not automatically detect changes in the system settings, but the CurrentRegion property is updated when you call the ClearCachedData method.


    MSDN.com - CultureInfo.ClearCachedData Method
    Information, such as the default culture and format patterns, is cached the first time it is requested. That information can change during the life of the AppDomain, for example, when the user modifies the regional and language options portion of Control Panel. However, the CultureInfo class does not automatically detect changes in the system settings.

    The ClearCachedData method clears the cache of CultureInfo objects created by GetCultureInfo and refreshes the information in the CurrentCulture, CurrentUICulture, and CurrentRegion properties, based on the current system settings.

    The ClearCachedData method does not refresh the information in the Thread.CurrentCulture property for existing threads. However, future threads will have any new CultureInfo property values.


  • Registered Users Posts: 7,501 ✭✭✭BrokenArrows


    Ok but how can i create a cultureinfo without defining the country i want the culture for?

    This defeats the purpose of automatically getting the currency!


  • Registered Users Posts: 1,235 ✭✭✭Odaise Gaelach


    new CultureInfo("").ClearCachedData();
    


  • Registered Users Posts: 7,501 ✭✭✭BrokenArrows


    CultureInfo ci = new CultureInfo("");
    ci.ClearCachedData();
    string currencySymbol = RegionInfo.CurrentRegion.ISOCurrencySymbol;


    currencySymbol string is still being reported as "GBP"


  • Registered Users Posts: 1,311 ✭✭✭Procasinator


    Could you be running the program under another account (typical for services and ASP.NET applications)?

    Maybe try:
    http://shadym.blogspot.ie/2010/07/changing-regional-settings-for-system_09.html


  • Advertisement
  • Registered Users Posts: 7,501 ✭✭✭BrokenArrows


    Could you be running the program under another account (typical for services and ASP.NET applications)?

    Maybe try:
    http://shadym.blogspot.ie/2010/07/changing-regional-settings-for-system_09.html

    Yup that was it.

    Thanks


Advertisement