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

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -