Click here to Skip to main content
15,923,051 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Occasionally, I need to execute a console command from my C# program, and take action based on the output. This works great if the region settings on the machine is set to English. Not so much for any other language.

Is there any way to get the language to be set to English only for the console process you spawn from your program?
Posted

1 solution

Set the culture of the program. It won't affect the user settings

VB
// C#
// Put the using statements at the beginning of the code module
using System.Threading;
using System.Globalization;
// Put the following code before InitializeComponent()
// Sets the culture to English(United States)
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
// Sets the UI culture to French (France)
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");


For more information:
http://msdn.microsoft.com/en-us/library/b28bx3bh(v=vs.80).aspx[^]

Please don't forget to mark this answer as a solution if it works :)
 
Share this answer
 
Comments
CertNerd 27-Apr-12 14:39pm    
Thanks so much for your help! This worked perfectly. Sorry it took me so long to try it out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900