Locale problem in C# program that I implemented. How to fix?

jazzIIIlove used Ask the Experts™
Hi there;

I have Locale (Regional Settings) problem in C# program that I implemented. I implemented the program in Locale of US but the target seems to use TR Locale.

Now, the client doesn't want to change his Locale to US. So, I have to fix it.

1) Is there library or function to supress the Windows Locale, I mean can I set Locale value as EN but with library to supress the Windows Locale?

To give an example, one functionality of the program is to have the System Time and write into a text file. In my US locale, it's as 7/6/2010 as 7 dentoes July whereas when I run the program in TR locale, the file content becomes 06.07.2010. I was splitting the date with '/' character and it fails in TR locale naturally. So, what should be the easiest way?

Best regards.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Once you get System date or time, use standard ways to extract month & day instead of splitting like


This will be independent of locale;
Continuing with some example from my previous comment
            System.DateTime datetime = System.DateTime.Now;
            int year = datetime.Year;
            int month = datetime.Month;
            int day = datetime.Day;
Hello, please mention what kind of application are you creating Web or Windows Forms. You could consider using culture for your application?
Here's a guide http://msdn.microsoft.com/en-us/library/b28bx3bh(VS.71).aspx.
I got it both as in my question, it seems the day and month are in reversed order, will it cause any problem?

That culture thing may help, let me check on this.

when you split you will get day and month in reverse but when you call the datetime.day & datetime.Month it always returns the correct value irrespective of the date format.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial