N Md Hussain
N Md Hussain

Reputation: 71

C# Changing sytem locale

Need to change the system locale to a different country, I have tried SystemParametersInfo(), GetKeyboardLayout() which didn't help.

How would I change the system locale in C# for a console application?

Upvotes: 7

Views: 4982

Answers (2)

user195488
user195488

Reputation:

e.g.,

 Thread.CurrentThread.CurrentCulture = new CultureInfo("es-AR"); // Espanol - Argentina
 Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-AR");// Espanol - Argentina

e.g,

 Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); // English - US
 Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");// English - US

Upvotes: 3

bitbonk
bitbonk

Reputation: 49609

You can use SetLocalInfo.

[DllImport("kernel32.dll")]
static extern bool SetLocaleInfo(uint Locale, uint LCType, string lpLCData);

Upvotes: 2

Related Questions