Rano AH

Rano AH

  • NA
  • 176
  • 111.5k

Log file Path

Sep 7 2013 5:06 AM
Hello

I'm trying to set a location/Path for my logFile but I cannot. It keeps creating it in the debug folder

            StreamWriter logFile;
            if (!File.Exists("logFile.txt"))
            {
                logFile = new StreamWriter(@"C:\logFile.txt");
            }
            else
            {
                logFile = File.AppendText("logFile.txt");
            }

What is wrong in my code? and what if I need to create a specific folder (LogFolder) under C: Directory for example (if the folder does not exist) so that I can create the logFile inside of it.


Answers (3)