It looks like the DateSeparator your CurrentCulture is - , and therefore / replace it with it.
"/" specifier of a special format is of particular importance, since I am replaced by the current culture or the culture date separator provided.
You have several options, you either escape it with single quotes (or \/ in the string literal of the string), or use a culture with / like DateSeparator , like InvariantCulture .
string s = DateTime.Now.ToString("M'/'d'/'yyyy"); string s = DateTime.Now.ToString(@"M\/d\/yyyy"); string s = DateTime.Now.ToString("M/d/yyyy", CultureInfo.InvariantCulture);
Soner gΓΆnΓΌl
source share