Search code examples
c#ioglobalization

Writing Date Value


I am writing some date values in US format (MMDDYYYY) using my programme to a csv file in c#. This is a WPF Application. If a user has different regional settings like UK in their computers the date values are flipping. how can i make sure that no matter what the users regional settings are my application will write the date values in the US format?


Solution

  • Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
    Console.WriteLine(dateToDisplay.ToString("MMddyyyy"));