I need to create some log files with a name like this: HH:mm_dd-MM-yyyy.log
I've tried to convert DateTime & DateTime.Now like this but the compiler encounters the next error:
The given path's format is not supported.
Code i've tried:
#1
var currentDateTime = DateTime.Now;
string format = "HH:mm_dd-MM-yyyy";
string datetime = currentDateTime.ToString(format);
File.Create("Log/GameLog/"+datetime+".log");
#2
string datetime = DateTime.Now.ToString("HH:mm_dd-MM-yyyy");
File.Create("Log/GameLog/"+datetime+".log");
In this couple of cases the same error was raised by the compiler... So in the end, my question is, how can i use datetime as a file name?