Using interpolation string & format specifier:
var filename = $"{DateTime.Now:yyyy.dd.M HH-mm-ss}"
Example Output for January 1st, 2020 at 10:40:45AM:
2020.28.01 10-40-45
Or if you want a standard date format:
var filename = $"{DateTime.Now:yyyy.M.dd HH-mm-ss}"
2020.01.28 10-40-45
Note: this feature is available in C# 6 and later versions of the language.