c# - Read date from file name -
what need convert string obtain reading file's name, in form of yyyymmdd.log
, transform in object of type 'datetime'.
the command use create file is:
string filepath = path.combine(filedailyenergysavinguppername, string.concat(date.tostring("yyyymmdd"), ".log"));
how convert string date?
edit: looking online found this: datetime mydate = datetime.parseexact(mystring, "yyyymmdd",null);
is correct?
have @
datetime.tryparseexact
e.g.
datetime datevalue; bool parsed = datetime.tryparseexact(datetime, "yyyymmdd", cultureinfo.invariantculture, datetimestyles.none, out datevalue);
Comments
Post a Comment