Using windows form application how to get OS region and language date format.
I want string mark in bold in below image.
Using windows form application how to get OS region and language date format.
I want string mark in bold in below image.
try this
System.Threading.Thread.CurrentThread.CurrentCulture.EnglishName
or
System.Threading.Thread.CurrentThread.CurrentCulture.DisplayName
result of above code is "Thai (Thailand)"
using System.Globalization;
CultureInfo culture = CultureInfo.CurrentUICulture; // get the culture of the OS
string cultureName = culture.DisplayName; // get its full name
This gives you the culture which was installed with the OS. There seem to be a couple of other static properties of CultureInfo, such as DefaultThreadCurrentCulture
and DefaultThreadCurrentUICulture
, which may give you what you're looking for.
See the documentation for CultureInfo
: http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo%28v=vs.110%29.aspx
This gives you the name of the culture that the thread is using.
Console.WriteLine(Thread.CurrentThread.CurrentCulture.Name);
This has been already answered: Previous answer
Try this,it will solve your problem:
class Region
{
public class Stateinfo
{
public CultureInfo Result { get; set; }
}
static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture.ClearCachedData();
var thread = new Thread(
s => ((Stateinfo)s).Result = Thread.CurrentThread.CurrentCulture);
var stateinfo= new Stateinfo();
thread.Start(stateinfo);
thread.Join();
var culture = stateinfo.Result;
}
}