Hello, I am parsing a string to convert it into a DateTime. I am geeting in some cases an error:
"String was not recognized as a valid DateTime."
I am getting this error only if I run the application from a computer located in a different country then US. What I see in the string is "09/20/2010 14:11" and in this case I get an exception. If I have a value like: "10/05/2010 12:54" I don't get an exception. I am to suppose is the fact that the day is 20 and this computer is in Europe, so it thinks that 20 is the month. The problem is I force it to be en-US:
CompletedDttm = DateTime.ParseExact(value, "MM/dd/yyyy hh:mm", new CultureInfo("en-US"));
Because I am getting the exception I suppose sure this is the correct approach.
Any idea how to parse a string in a way that works no matter what culture I am running on the machine?
Thanks Tony