I need to store exact DateTime as a filename, and restore it when needed.
Pattern dd_MM_yyyy hh_mm_ss_ff tt doesn't seem to match the original date (after using DateTime.ParseExact, so I believe part of the date is lost upon conversion. Is ticks the smallest part of DateTime? How to save it to string as well?
I believe you want to reliably time-stamp your log file. Well, the format you provide will not be reliable, i.e. it will look different depending on Thread's CurrentCulture value.
I would recommend using something like "yyyy-MM-dd_HH:mm:ss.FFFFFFF" if you want to have precise and reliable time stamp.
Yes, ticks represent the smallest measurement on a DateTime.
String filename = DateTime.Now.Ticks + ".txt";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With