I'm trying to create a C# console application that will generate a log file. I'd like to have some flexibility with where the log file will be stored.
I tried using the Settings.settings file with:
Name: logDrive Type: string Scope: Application Value: C:\Scripts\Logs
In my code, I'm using:
string logFile = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
logFile = logFile.Replace(@"/", @"-").Replace(@"\", @"-") + ".log";
string logDrive = Properties.Settings.Default.logDrive;
StreamWriter output = new StreamWriter(logDrive + logFile);
When compiling the above I get the error message "The given path's format is not support."
If it helps, the values for:
logDrive = "C:\Scripts\ServiceDesk\Logs" logFile = "3-23-2009 1:20 PM.log"
Does anyone have any thoughts/ recommendations for a better approach and/ or what I'm doing wrong?