I have dates comming in a log file with the following format: "dMMyyHHmmss".
As I want to throw an exception if the format found is not exactly that one, I'm using DateTime.ParseExact. The thing is that I'm getting a FormatException with the following message:
'String '.....' was not recognized as a valid DateTime.
The code to emulate this is:
var format = "dMMyyHHmmss";
var date = new DateTime(2018, 1, 1, 1, 1, 1);
var strDate = date.ToString(format);
date = DateTime.ParseExact(strDate, format, CultureInfo.InvariantCulture);
Any thoughts why I can't use that format?