I am getting error to create a file While used string variable as current time in filename. Error as
An unhandled exception of type 'System.NotSupportedException' occurred in mscorlib.dll
Additional information: The given path's format is not supported.
I couldn't find what is wrong in the code and I tried without "path" variable it will successfully run. I didn't understand what is happening when I used "cTime" variable for create dynamic filename.
static void Main(string[] args)
{
string path = @"C:\\Reminder_Logs\\";
string cTime = DateTime.Now.ToString("HH:mm").Trim();
using (StreamWriter srRun = File.AppendText(path + "log_Reminder_" + cTime + ".txt"))
{
using (StreamWriter sr = File.AppendText(path + "log_Start.txt"))
{
sr.WriteLine("reminder file created!!! " + DateTime.Now.ToString("HH:mm"));
}
}
}
string cTime = DateTime.Now.ToString("HH_mm").Trim();