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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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

  • 07-08-2012 2:13pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 1,235 ✭✭✭Odaise Gaelach


    new CultureInfo("").ClearCachedData();
    


  • Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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